Calldata checks require an unvalidated byte in between calldata segments which leads to flawed validation #31
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
duplicate-17
🤖_10_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-10-kleidi/blob/ab89bcb443249e1524496b694ddb19e298dca799/src/Timelock.sol#L1034-L1155
Vulnerability details
Vulnerability Details
Impact
When a call is whitelisted, either during the creation of the system instance or when a proposal to
addCalldataCheck()
oraddCalldataChecks()
is executed, the required data needs to be provided.This includes, among other things, the
startIndex
andendIndex
of each calldata segment.During the whitelisting process,
_addCalldataCheck()
inTimelock.sol
is called. This function checks that thestartIndex
andendIndex
of the calldata do not partially overlap with other indexes.However, this check incorrectly interprets the calldatas, which could result in the execution to be completely different. For example, an amount that needs to be transferred could be larger than the user intended.
Proof of Concept
The following test needs to be added to
Timelock.t.sol
:The test first sets the necessary variables and then calls
addCalldataChecks()
as the timelock.The important variables are the start and endIndexes, which are set as follows:
Currently, due to a bug in the code, it is not possible to add these two calldata segments because one unvalidated byte is required between them.
Further details are described in the comments within the test.
The cold signers would provide calldata checks in such a way that there is no revert while also expecting that there is no unvalidated byte. As a result the validation that is expected by the cold signers deviates from the validation that is actually performed and unintented calldata can slip through and be executed by the hot signers.
Recommended Mitigation Steps
The following changes should be made in
Timelock._addCalldataCheck()
:Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: