AuraSpell#closePositionFarm exits pool with single token and without any slippage protection
The closePositionFarm function in AuraSpell exits a Balancer pool with an empty array for minAmountsOut, providing no slippage protection. An attacker could sandwich attack the exit, causing massive loss to the user.
0x52 Follow with Breeje, Oxhunter526 and 3 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-07-blueberry-judging/issues/102
Found by
0x52, Breeje, Oxhunter526, Vagner, bitsurfer, nobody2018
When exiting the balancer pool, vault#exitPool is called with an empty array for minAmountsOut causing the position to be exited with no slippage protection. Typically it is not an issue to exit off axis but since it is exiting to a single token this can cause massive loss.
Vulnerability Detail
(
uint256[] memory minAmountsOut,
address[] memory tokens,
uint256 borrowTokenIndex
) = _getExitPoolParams(param.borrowToken, lpToken);
wAuraPools.getVault(lpToken).exitPool(
IBalancerPool(lpToken).getPoolId(),
address(this),
address(this),
IBalancerVault.ExitPoolRequest(
tokens,
minAmountsOut,
abi.encode(0, amountPosRemove, borrowTokenIndex),
false
)
When exiting a the balancer vault, closePositionFarm makes a subcall to _getExitPoolParams which is used to set minAmountsOut.
(address[] memory tokens, , ) = wAuraPools.getPoolTokens(lpToken);
uint256 length = tokens.length;
uint256[] memory minAmountsOut = new uint256[](length);
Inside _getExitPoolParams we see that minAmountsOut are always an empty array. This means that the user has no slippage protection and can be sandwich attacked, suffering massive losses.
Impact
Exits can be sandwich attacked causing massive loss to the user
Code Snippet
Tool used
Manual Review
Recommendation
Allow user to specify min amount received from exit
Discussion
securitygrid
Escalate: Historically, lacking slippage protection is H.
sherlock-admin2
Escalate: Historically, lacking slippage protection is H.
You've created a valid escalation!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
Shogoki
Escalate: Historically, lacking slippage protection is H.
Can be a high issue
IAm0x52
Why would lack of slippage be considered high in this scenario? Even with zero slippage protection sandwich attack profitability is always contingent on a few external factors such as: liquidity of underlying pool, the fee of the underlying pool, the amount being swapped and the current gas prices. The higher the liquidity and fee of the pool the higher the cost to push the pool price then pull it back. The lower the amount being swapped, the less the attacker can steal. If this cost exceeds the gain from the attack then the attack isn't profitable and won't happen.
VagnerAndrei26
I think no slippage is considered high most of the time cause sandwich attacks are easily doable in the space, especially for those experienced in doing it, and even if there are factors to consider even one successful can occur loss of funds for the protocol in a pretty easy manner. So considering that and also past contests I think it should be considered also a high.
Nabeel-javaid
as far as I know 98% of the times slippage issues are considered as Medium severity
hrishibhat
Result: Medium Has duplicates This is a valid medium issue. Agree with the Lead Watson's comments here: https://github.com/sherlock-audit/2023-07-blueberry-judging/issues/102#issuecomment-1699649100
sherlock-admin2
Escalations have been resolved successfully!
Escalation status:
- securitygrid: rejected
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 function _getExitPoolParams returns an empty array for minAmountsOut, so no slippage protection is applied when exiting the pool.
Impact
Exits can be sandwich attacked causing massive loss to the user.
What the attacker needed
User calls closePositionFarm; Attacker can sandwich attack
The fix
Allow the user to specify a minimum amount received from the exit.
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.
When you withdraw money from a trading pool, you can set a minimum amount you are willing to accept to protect against price changes. Here, the code sets that minimum to zero, so an attacker can manipulate the price and steal value from your withdrawal.
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.