The contract IDIVA.sol does not seem to use SafeMath for arithmetic operations on variables like capacity, floor, collateralBalance, and gradient. This could lead to overflows or underflows in some cases.
The Fees struct contains protocolFee and settlementFee, each defined as uint96. The comment indicates a maximum expected value of 1.5% (15000000000000000), but the protocol does not explicitly enforce this constraint, making it possible to set an unintended large value.
PoolParams struct contains several parameters that involve calculations (e.g., gradient, floor, cap). Since gradient is stored in collateral token decimals, any multiplication might cause unexpected overflows or underflows.
addLiquidity function accepts a user-defined _collateralAmountIncr. If this amount is excessively large, calculations involving collateralBalance may reach unintended states.
If large values are used in fee calculations or pool parameters, they might exceed the expected ranges, causing unexpected behavior.
Some values, such as gradient, collateralAmount, and capacity, involve multiplication and division, which could cause precision loss or unexpected results.
Proof of Concept (PoC)
Actors:
Attacker: A malicious user providing large values to break calculations.
Protocol: IDIVA contract.
Victim: Honest users expecting correct calculations.
Exploit Scenario:
The attacker calls createContingentPool with an extremely large gradient value near type(uint256).max.
During calculations, gradient might cause unexpected precision issues or overflow.
If gradient * collateralAmount is computed without proper constraints, it could break the contract’s logic.
Similarly, fees set via Fees struct could be manipulated to an extreme value, disrupting correct fee deductions.
PoC Code - Overflow in Gradient Calculation
Outcome & Implications
If the contract does not properly validate gradient, a multiplication involving gradient and collateralAmount could overflow, breaking position token calculations.
This could lead to:
Incorrect payouts.
Stuck collateral.
Manipulated fee calculations.
Manual code review
✅ Enforce Limits on Input Values
Ensure that gradient, protocolFee, and settlementFee have explicit max bounds.
Add constraints before calculations.
✅ Use Safe Math for Multiplication and Division
Even though Solidity 0.8+ has built-in overflow checks, using additional constraints ensures calculations remain within safe limits.
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.