During withdraw of token via withdraw(uint256 poolId_, uint256 amount_)
function in case of public pool , which internally calls _withdraw(address user_, uint256 poolId_, uint256 amount_, uint256 currentPoolRate_)
, Attacker/user with some deposited amount in pool can withdraw all its deposited token and set the newDeposited_
to Large value due to underflow of deposited_ - amount_
value, and thus can drain all the tokens from the contract . This is possible in case when amount > depositedTokenCOntractBalance
and userData.deposited / deposited_ < depositedTokenCOntractBalance
.
In the function below
// // @audit overflow , ex deposited - 50 , amount - 1000, depositedTokenCOntractBalance - 500
Lets say
pool = public
deposited_ = 50
amount_ = 1000
depositedTokenContractBalance = 500
at i) amount_ > deposited_
thus , amount = 50;
at ii) pool is public , thus goes inside if function
Now lets say , depositedTokenContractBalance = 500
at iii) amount_ > depositedTokenContractBalance
thus , amount_ = 1000;
at iv) newDeposited_ = deposited_ - amount_;
newDeposited = 50 - 1000 (Underflow)
thus newDeposited = veryLarge Number .
Critical
Hardhat, remix
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.