-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to set to check consecutive parameters #2
Comments
This is a good finding, and it makes sense that it is a medium issue. |
This seems to be valid, will check POC and mitigation as well |
Great catch, thank you! |
It seems like this and #17 are dups / tighly related |
GalloDaSballo marked the issue as selected for report |
Leaving 2 and 17 as separate for now, I think mitigation will require both, but they seem to be 2 instances of 2 different off by one errors |
fix is in here: solidity-labs-io/kleidi#51 |
I am requesting re-considering the selected report. This report doesn't correctly states the problem. The PoC is using uint16 data type but in low-level So, the demonstrated calldata is completely wrong in the selected report. Uint16 is not affected in here because EVM will already revert if we send only 2 bytes data for uint16, instead we should send 32 bytes with padded zeros and we don’t need to restrict first 8 bits of the parameter because if it’s not zero, EVM will revert for us. In order to see the effect of the bug we can only look at the data types which has 32 bytes.
|
GalloDaSballo marked the issue as not selected for report |
GalloDaSballo marked issue #17 as primary and marked this issue as a duplicate of 17 |
GalloDaSballo marked the issue as satisfactory |
Lines of code
https://github.com/code-423n4/2024-10-kleidi/blob/ab89bcb443249e1524496b694ddb19e298dca799/src/Timelock.sol#L1119-L1123
https://github.com/code-423n4/2024-10-kleidi/blob/ab89bcb443249e1524496b694ddb19e298dca799/src/BytesHelper.sol#L35-L67
Vulnerability details
Impact
Unable to check hot signer call parameters precisely.
Proof of Concept
When checking call parameters, the [start, end) of the call parameters, that is, from index [start] to [end-1], are parsed and checked.
For example, let's say
start
is 4 andend
is 6.sliceBytes
parses 2 bytes, and the parsed bytes are data[4] and data[5].Therefore, when verifying parameters of a function with multiple parameters, the
startIndex
of the next parameter should be set to be the same as theendIndex
of the previous parameter(When parameters are contiguous).For example, let's say we allow a
function deposit(uint16, uint16)
and want to check both parameters. To check this, the call parameters are parsed as follows:To parse this, the Index should be set as follows:
_calldataList[contractAddress][selector][0]
)_calldataList[contractAddress][selector][1]
)However, when registering the Index, it is restricted from setting the next
startIndex
to be the same as the previousendIndex
. Therefore, it is not possible to check consecutive parameters.This is the PoC:
First, we demonstrate that
sliceBytes
parses [start]~[end-1]. Add this test at BytesHelper.t.sol file to run it.This demonstrates that in
addCalldataCheck
, it's not possible to set the nextstartIndex
to be the same as the previousendIndex
, making it impossible to set up checking for consecutive parameters. Add this test at CalldataList.t.sol file to run it.Tools Used
Manual Review
Recommended Mitigation Steps
Assessed type
Other
The text was updated successfully, but these errors were encountered: