Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: medium
Invalid

Unvalidated Token Path Length

Summary

Vulnerability Details

In the executeSwapExactInput function, the swap path is decoded from a bytes-encoded field:

(address[] memory tokens, ) = swapPayload.path.decodePath();
  • The function then uses the decoded tokens array in a for‑loop:

    `for (uint256 i; i < tokens.length - 1; i++) { … }
  • There is no check to confirm that the decoded array has at least two elements

  • If swapPayload.path is empty or improperly encoded, the tokens array might have fewer than two addresses. The loop condition tokens.length - 1 would underflow (if tokens.length is 0) or the loop would not execute as expected.

Impact

An attacker could provide an invalid swap path that causes the function to revert, thereby blocking the swap functionality

Tools Used

manual

Recommendations

**Validate the Swap Path:**Immediately after decoding, insert a check:

require(tokens.length >= 2, "CurveAdapter: invalid swap path");

Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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