All supplied WETH to Aave as a deposit by a Strategy will be irrecoverable
The strategy deposits leftover WETH into Aave after a debt repayment swap, but it has no way to withdraw WETH from Aave, so those funds become permanently stuck. An attacker cannot directly exploit this, but any user triggering the strategy will lose the excess WETH.
Submitted by 0xStalin, also found by zhaojie
Impact
WETH supplied to Aave will be lost.
Proof of Concept
When a strategy pays debt on Aave it does a swap of the withdrawn collateral from Aave in exchange for WETH. After the swap is completed, it checks if there are any weth leftovers after the swap, if so, it deposits them back. The problem with this approach is that the strategy doesn’t have any means to pull WETH out of Aave, the strategy is only capable of withdrawing the collateral from Aave, but not WETH.
function _payDebt(uint256 debtAmount, uint256 fee) internal {
...
//@audit-info => output represents the received amount of WETH for the swap
uint256 output = _swap(
ISwapHandler.SwapParams(
ierc20A(),
wETHA(),
ISwapHandler.SwapType.EXACT_OUTPUT,
amountIn,
debtAmount + fee,
_swapFeeTier,
bytes("")
)
);
//@audit-info => Checks if there are any WETH leftovers
// When there are leftovers from the swap, deposit then back
uint256 wethLefts = output > (debtAmount + fee) ? output - (debtAmount + fee) : 0;
//@audit-issue => If any leftover WETH, it deposits them onto Aave!
//@audit-issue => Once the WETH is deposited in Aave, the Strategy won't be able to pull it out.
if (wethLefts > 0) {
_supply(wETHA(), wethLefts);
}
emit StrategyUndeploy(msg.sender, debtAmount);
}
The strategy uses the StrategyAAVEv3._withdraw() function to withdraw an asset from Aave, but, in the places where this function is called, the only assets requested to be withdrawn is the Collateral.
Recommended Mitigation Steps
Instead of supplying the wethLefts, use the excess WETH to repay more WETH debt on Aave, in this way, those extra WETHs won’t be lost on Aave because the strategy doesn’t have any means to withdraw them.
- By using the extra WETH to repay more debt, the loan to value is brought down even to a healthier level.
function _payDebt(uint256 debtAmount, uint256 fee) internal {
...
...
...
//@audit => Instead of supplying WETH to Aave, use it to repay more debt
if (wethLefts > 0) {
- _supply(wETHA(), wethLefts);
+ _repay(wETHA(), wethLefts);
}
emit StrategyUndeploy(msg.sender, debtAmount);
}
hvasconcelos (BakerFi) confirmed
Fixed → https://github.com/baker-fi/bakerfi-contracts/pull/42
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The strategy supplies leftover WETH to Aave without having any function to withdraw WETH, only collateral.
Impact
Any WETH supplied to Aave as a leftover deposit will be permanently lost because the strategy cannot withdraw it.
What the attacker needed
Strategy performs a debt repayment swap; swap output exceeds debt plus fee
The fix
The strategy should use the excess WETH to repay more debt instead of supplying it to Aave; the issue was fixed in a pull request.
How it was found
- The strategy pays debt on Aave by swapping withdrawn collateral for WETH.
- After the swap, it checks if there is leftover WETH beyond the debt and fee.
- If leftovers exist, it supplies that WETH back to Aave.
- The strategy later tries to withdraw assets from Aave but only requests collateral, never WETH.
- The supplied WETH remains stuck in Aave because the strategy cannot withdraw it.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract strategy swaps some collateral for WETH to pay off a loan. If it gets more WETH than needed, it puts the extra WETH back into the lending pool (Aave) as a deposit. But the strategy only knows how to take out the original collateral, not WETH, so that extra deposit can never be retrieved.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.