The VaultCDepositController::withdraw contains the logic to withdraw tokens from the vault and send them to the staking pool. It handles the logic flaw for several scenarios:
The withdrawal amount (toWithdraw) is greater than the vault's current deposits (deposits).
The withdrawal amount is less than the vault's deposits and the withdrawal would leave less than the minimum deposits in the vault.
Normal withdrawal (default case).
In the second scenario, this flaw causes the contract to withdraw an incorrect (greater than the requested ) amount of tokens from the vault, leading to a loss of funds for the vault.
In the second case of the withdrawal logic, the contract checks if the withdrawal amount is less than the vault's deposits and the withdrawal would leave less than the minimum deposits in the vault. Then proceeds to withdraw the funds but it withdraws the full deposits amount that is greater than the intended toWithdraw amount requested. This results in an excessive withdrawal that leaves the vault with fewer funds than expected.
Scenario:
toWithdraw = 20
deposits = 60
minDeposits = 50
toWithdraw = 20 > deposits = 60 the system enters the first elseif statement:
deposits - toWithdraw = 60 - 20 = 40 > 0 && deposits - toWithdraw = 60 - 20 = 40 < minDeposits = 50 that returns true
The system proceeds with the withdrawal (vault.withdraw(deposits)). But it withdraws the wrong amount (deposits = 60) which is greater than the amount requested (that was toWithdraw = 20). The system withdraws 40 more than necessary.
The contract transfers to the staking pool more funds than intended with a funds loss for the Vault.
Manual review
Modify the second case in the withdrawal logic as follows:
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.