Part 2

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

Integer Overflow/Underflow Risk in withdrawMarginUsd

Description

Arithmetic operations involving amountToWithdrawUsd and marginCollateralPriceUsd could overflow or underflow if not properly constrained.

Summary

Extremely large values for amountToWithdrawUsd or marginCollateralPriceUsd could cause unexpected behavior.


Vulnerability Details

  • Issue: The function does not explicitly check for overflow/underflow in arithmetic operations.

  • Example: Multiplying amountToWithdrawUsd by marginCollateralPriceUsd could exceed uint256 limits.


Impact

  • Incorrect calculations could result in incorrect withdrawals or contract state corruption.


Tools Used

  • Manual Code Review

  • Foundry/Forge


Recommendations

  • Add explicit checks for overflow/underflow.

require(amountToWithdrawUsd <= type(uint256).max / marginCollateralPriceUsd, "Overflow risk");

Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Out of scope

Support

FAQs

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