ShortLongSpell#_withdraw checks slippage limit but never applies it making it useless
The _withdraw function in ShortLongSpell checks the sell slippage limit but never applies it, so the protection is ineffective. An attacker could exploit this to extract value via swaps if they find a way to trick collateral requirements.
Source: https://github.com/sherlock-audit/2023-04-blueberry-judging/issues/126
Found by
0x52, Ch_301
Summary
Slippage limits protect the protocol in the event that a malicious user wants to extract value via swaps, this is an important protection in the event that a user finds a way to trick collateral requirements. Currently the sell slippage is checked but never applied so it is useless.
Vulnerability Detail
See summary.
Impact
Slippage limit protections are ineffective for ShortLongSpell
Code Snippet
Tool used
Manual Review
Recommendation
Apply sell slippage after it is checked
Discussion
securitygrid
Escalate for 10 USDC This is not a valid M/H. The toAmont and expectedAmount in the off-chain parameter MegaSwapSellData structure are the real slippage protection parameters. Just like ExactInputParams/ExactOutputParams of uniswapV3 pool.
sherlock-admin
Escalate for 10 USDC This is not a valid M/H. The toAmont and expectedAmount in the off-chain parameter MegaSwapSellData structure are the real slippage protection parameters. Just like ExactInputParams/ExactOutputParams of uniswapV3 pool.
You've created a valid escalation for 10 USDC!
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.
ctf-sec
I still think this is a valid issue
sellSlippage checked but not applied
function _withdraw(
ClosePosParam calldata param,
Utils.MegaSwapSellData calldata swapData
) internal {
if (param.sellSlippage > bank.config().maxSlippageOfClose())
revert Errors.RATIO_TOO_HIGH(param.sellSlippage);
it is true that the slippage is checked but not applied
The toAmont and expectedAmount in the off-chain parameter MegaSwapSellData structure are the real slippage protection parameters. Just like ExactInputParams/ExactOutputParams of uniswapV3 pool.
this is true, but the code should still check the slippage based on the received amount instead of off-chain parameter
hrishibhat
Escalation rejected
Valid high Agree with the Lead judge comment. Slippage must be checked on code whenever possible instead of an off-chain parameter.
sherlock-admin
Escalation rejected
Valid high Agree with the Lead judge comment. Slippage must be checked on code whenever possible instead of an off-chain parameter.
This issue's escalations have been rejected!
Watsons who escalated this issue will have their escalation amount deducted from their next payout.
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
Likely the code checks the sell slippage parameter but fails to use it to constrain the swap, so the limit has no effect.
Impact
Slippage limit protections are ineffective for ShortLongSpell, which could allow value extraction if collateral requirements are bypassed.
What the attacker needed
Attacker can trick collateral requirements
The fix
The sell slippage should be applied after it is checked, and the check should be based on the received amount rather than an off-chain parameter.
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.
Slippage is the difference between the expected price and the actual price when trading. A slippage limit stops trades that would give too little back. Here, the code checks the limit but then ignores it, so trades can go through even if the price is much worse than allowed.
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.