The calldata checks which don't overlap partially can't be added. #50
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/main/src/Timelock.sol#L1120-L1121
Vulnerability details
Proof of Concept
[Root cause]
Timelock._addCalldataCheck()
function is the following.As can be seen,
L1121
uses strict inequality>
instead of>=
andL1122
uses strict inequality '<' instead of<=
. Therefore, the function will revert if the two calldatas are for two consecutive parameters respectively.[Proof of Concept]
For instance, assume that the
contractAddress
is the address of the following MockLending contract and theselector
is for thedeposit()
function.Then, in the calldata to
deposit()
function,0~3
bytes are for function selector,4~23
bytes are forto
parameter and24~55
bytes are foramount
parameter.Assume that we want to whitelist the calls for two cases where
to = 0x1234
oramount = 1e18
respectively: For the first case, We have to calladdCalldataCheck()
function withstartIndex = 4, endIndex = 24, to = 0x1234
. And after that, for the second case, we have to calladdCalldataCheck()
function withstartIndex = 24, endIndex = 56, amount = 1e18
. In the second call, the function will revert atL1121
becausestartIndex = 24
andindexes[0].endIndex = 24
is equal.Add the following test code into
CalldataList.t.sol
.The output of the above test code is the following.
As can be seen, although The two calldata check don't overlap (4
23 and 2455 bytes), the function call was reverted.Recommended Mitigation Steps
Modify the
Timelock._addCalldataCheck()
function as follows.Assessed type
Error
The text was updated successfully, but these errors were encountered: