NFTBridge
60,000 USDC
View results
Submission Details
Severity: low
Invalid

Incorrect payload length check in depositTokens() function

Summary

There is an incorrect payload length check in depositTokens() function.

Vulnerability Details

The MAX_PAYLOAD_LENGTH is 300.

uint256 constant MAX_PAYLOAD_LENGTH = 300;

https://github.com/Cyfrin/2024-07-ark-project/blob/273b7b94986d3914d5ee737c99a59ec8728b1517/apps/blockchain/ethereum/src/Bridge.sol#L25C1-L25C43

However, in the depositTokens function of the bridge contract, there is an incorrect check for the maximum payload length. The current implementation reverts the transaction if the payload length is greater than or equal to MAX_PAYLOAD_LENGTH, when it should only revert if the length is strictly greater than MAX_PAYLOAD_LENGTH.

if (payload.length >= MAX_PAYLOAD_LENGTH) {
revert TooManyTokensError();
}

https://github.com/Cyfrin/2024-07-ark-project/blob/273b7b94986d3914d5ee737c99a59ec8728b1517/apps/blockchain/ethereum/src/Bridge.sol#L134C8-L136C10

The issue stems from the use of the greater than or equal to operator (>=) instead of the strictly greater than operator (>) in the payload length check. This check incorrectly includes the case where payload.length is exactly equal to MAX_PAYLOAD_LENGTH, which should be a valid case.

Impact

Valid transactions with a payload length exactly equal to MAX_PAYLOAD_LENGTH are incorrectly rejected. This reduces the maximum number of tokens that can be deposited in a single transaction by one.

Tools Used

Manual review

Recommendations

Modify the payload length check to use the strictly greater than operator:

if (payload.length > MAX_PAYLOAD_LENGTH) {
revert TooManyTokensError();
}
Updates

Lead Judging Commences

n0kto Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational / Gas

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.

Appeal created

sabit Submitter
10 months ago
n0kto Lead Judge
9 months ago
n0kto Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational / Gas

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.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.