The increasePosition
and decreasePosition
functions in the LiquidationPool contract should implement checks to prevent potential integer underflow when deducting values from positions[msg.sender].TST
and positions[msg.sender].EUROs
.
The vulnerability arises from the lack of proper checks to prevent integer underflow when deducting values in the decreasePosition
function.
The absence of checks to prevent integer underflow in the decreasePosition
function may lead to unexpected behavior, including potential loss of funds. An attacker could potentially manipulate the function parameters to trigger underflow and exploit the contract.
VsCode / Manual Code Review
To address the potential integer underflow vulnerability in the increasePosition
and decreasePosition
functions of the LiquidationPool contract, the following recommendations are provided:
Implement Checks Before Deducting Values:
Prior to deducting values from positions[msg.sender].TST
and positions[msg.sender].EUROs
, incorporate checks to ensure that the deducted amounts do not exceed the existing balances. This prevents potential integer underflow scenarios.
Conduct Comprehensive Testing:
Prior to deploying the contract, conduct comprehensive testing, including unit tests and scenario-based testing, to ensure that the implemented checks effectively prevent integer underflow situations.
Leverage SafeMath Library:
Consider using the SafeMath library or similar mechanisms to perform arithmetic operations with additional safety checks. SafeMath helps prevent integer overflows and underflows, enhancing the overall security of the contract.
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.