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");
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.