Unable to create a calldata check immediately adjacent to an existing one #29
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
duplicate-17
edited-by-warden
🤖_primary
AI based primary recommendation
🤖_24_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/solidity-labs-io/kleidi/blob/0d72b6cb5725c1380212dc76257da96fcfacf22f/src/Timelock.sol#L1120-L1121
Vulnerability details
Impact
This vulnerability will prevent the creation of a calldata check map as intended.
Proof of Concept
The
Timelock::checkCalldata()
function verifies the whitelisted status of calldata by invokingBytesHelper.getSlicedBytesHash()
which internally callsBytesHelper.sliceBytes()
.src/Timelock.sol#L495-L502
The
sliceBytes()
function grabs a slice of bytes bystart
andend
indexes.From the above code snippet, we can see that the function takes a slice by the range
[start, end - 1]
.However, when creating a calldata check map by using the
Timelock::_addCalldataCheck()
function, the function checks the overlapping status between new range and existing ones by the following lines:Let's assume
S1, E1
is an existing range. Then, the new range to be added can be put into either within[E1+1, +Inf)
or[4, S1-1]
.But, as
sliceBytes()
takes a slice fromS1
toE1 - 1
, the indexE1
cannot be occupied by calldata checks.If there are several ranges, their end indexes will not be included as calldata check region.
Tools Used
Manual Review
Recommended Mitigation Steps
There are 2 alternative mitigation ways:
GTE
andLTE
comparison operators rather thanGT
andLT
like the below:sliceBytes()
function takes a slice of bytes fromstart
toend
, not toend - 1
.Assessed type
Invalid Validation
The text was updated successfully, but these errors were encountered: