The bridge contract contains multiple off-by-one errors affecting token deposits and transfers. These errors prevent valid Starknet addresses from receiving tokens and incorrectly reject maximum payload lengths, potentially breaking bridging functionality for certain users and transactions.
This function is used to deposit tokens in the escrow and initiates the
transfer to Starknet, issue here however is the fact that a valid ownerL2
address might not be able to receive these tokens on the Starknet chain, this is because the isFelt252
check is non-inclusive, i.e https://github.com/Cyfrin/2024-07-ark-project/blob/273b7b94986d3914d5ee737c99a59ec8728b1517/apps/blockchain/ethereum/src/sn/Cairo.sol#L51-L60
But SN_MODULUS is defined as https://github.com/Cyfrin/2024-07-ark-project/blob/273b7b94986d3914d5ee737c99a59ec8728b1517/apps/blockchain/ethereum/src/sn/Cairo.sol#L14-L21
Per the comment we can see that this edge value: 3618502788666131213697322783095070105623107215331596699973092056135872020481
is also to be considered a felt32
, however since the check is non inclusive an address that matches this would always revert.
Now there also exist the check here while depositing in the bridge, i.e https://github.com/Cyfrin/2024-07-ark-project/blob/273b7b94986d3914d5ee737c99a59ec8728b1517/apps/blockchain/ethereum/src/Bridge.sol#L134-L136
Problem with this is the fact that the payload.length
should be allowed to be = MAX_PAYLOAD_LENGTH
since that't the max accepted, but currently it always reverts when that's the case.
Attach the tests below here
The bridging functionality would be permanently broken for said valid felt32 user.
For the second case, valid payload lengths would be assumed as invalid and the attempt at bridging would be broken.
Manual review
Consider applying these changes:
Also
Please, do not suppose impacts, think about the real impact of the bug and check the CodeHawks documentation to confirm: https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity A PoC always helps to understand the real impact possible.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.