Open code423n4 opened 1 year ago
mubaris marked the issue as disagree with severity
mubaris marked the issue as sponsor acknowledged
JustDravee changed the severity to 2 (Med Risk)
JustDravee marked the issue as satisfactory
JustDravee marked the issue as selected for report
Lines of code
https://github.com/code-423n4/2023-03-polynomial/blob/main/src/KangarooVault.sol#L792 https://github.com/code-423n4/2023-03-polynomial/blob/main/src/KangarooVault.sol#L279
Vulnerability details
Impact
KangarooVault contract can't close the trades and users can't withdraw from it, then users and KangarooVaults will lose a lot of funds.
Proof of concept
usedFunds
is the uint256 variable which tracks the funds utilitized from the vault. AndtotalFunds
is the uin256 variable which tracks the funds claimed by vault from profits and users' depositing.KangarooVault
has no check iftotalFunds
>=usedFunds
whenusedFunds
is increased (transfer from vault) ortotalFunds
is decreased (transfer to vault).usedFunds
can be greater thantotalFunds
because the vault can transfer out more thantotalFunds
.usedFunds
>totalFunds
, KangarooVault can not close its trades because it will revert on underflow in function_resetTrade
:When
usedFunds
>totalFunds
, user can't not withdraw by functionprocessWithdrawalQueue
because it will revert on underflow.Scenerio:
totalFunds
= 1000 SUSD,usedFunds
= 0totalFunds
andusedFunds
usedFunds
= 2000usedFunds
>totalFunds
(2000 > 1000) then KangarooVault can't close its positionTool used
Manual Review
Recommended Mitigation Steps
Should add the checks if
totalFunds
>=usedFunds
when increasingusedfunds
or decreasingtotalFunds
in contractKangarooVault.sol