In the _withdrawSingle function of WithdrawHandler, the funds are withdrawn directly from the vault adapters when the withdrawal is small. However, the tokenAmount is not checked to be less than or equal to adapter.totalAssets() before withdrawing. If the amount to withdrawal is greater than the adapter's total assets, the transaction fails without returning proper error messages. Notice that a similar function, _withdrawBalanced, does check the adapter's balance (line 332).
Handle
shw
Vulnerability details
Impact
In the
_withdrawSingle
function ofWithdrawHandler
, the funds are withdrawn directly from the vault adapters when the withdrawal is small. However, thetokenAmount
is not checked to be less than or equal toadapter.totalAssets()
before withdrawing. If the amount to withdrawal is greater than the adapter's total assets, the transaction fails without returning proper error messages. Notice that a similar function,_withdrawBalanced
, does check the adapter's balance (line 332).Proof of Concept
Referenced code: WithdrawHandler.sol#L299-L300
Recommended Mitigation Steps
Add
require(tokenAmount <= adapter.totalAssets(), "_withdrawSingle: !adapterBalance");
after line 299.