Part 2

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

Overflow risk in function _convertUsdcToAssets( could cause DOS

Summary

A possible overflow issue will occur if the usdcAmount (a uint256) is explicitly or implicitly cast to uint128 causing a Denial of Service Attack.

Line of Code

Here is the Line of Code in question:

Vulnerability Details

Overflow Scenario

  1. Implicit/Explicit Casting: If the usdcAmount (a uint256) is cast to uint128 in the unshown logic (e.g., in the else block when interacting with external protocols or functions that expect uint128), it could overflow.

    • Example: uint128 amount = uint128(usdcAmount);

  2. Truncation Risk: If usdcAmount exceeds 2^128 - 1, casting it to uint128 truncates the higher bits, resulting in an incorrect value (e.g., 2^128 becomes 0).

Impact

This Overflow risk will cause DOS which will bring about inconsistency in the conversion of Usdc to Assets putting funds at risk.

Tools Used

Manual Review

Recommendations

Use explicit checks or SafeCast to handle the conversion safely

// Using OpenZeppelin's SafeCast````import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";

// In the code:````uint128 safeUsdcAmount = SafeCast.toUint128(usdcAmount); // Reverts on overflow

Updates

Lead Judging Commences

inallhonesty Lead Judge
4 months ago
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.