No slippage control on maker LP `deposit()`/`withdraw()`
The maker LP deposit and withdraw functions lack slippage control, so users cannot specify a minimum amount of collateral to receive. An attacker could exploit a flash crash to cause a user to receive half the expected amount when redeeming shares.
Source: https://github.com/sherlock-audit/2024-02-perpetual-judging/issues/121
The protocol has acknowledged this issue.
Found by
0xRobocop, Bauer, IllIllI, PUSH0, ni8mare
Summary
There are no slippage control arguments for maker LP deposit()/withdraw()
Vulnerability Detail
There are no arguments to the deposit()/withdraw() functions to limit the amount of collateral lost to market movements, and there are no preview functions to allow a UI to show how much collateral would be received when shares are redeemed.
Impact
A user may submit a transaction to redeem approximately $100 worth of shares given base price X, but when the block gets mined two seconds later, the price is at 0.5X due to a flash crash. By the time the user sees what they got, the crash has been arbitraged away, and the base price is back at price X, with the user having gotten half the amount they should have.
Code Snippet
Users can only specify inputs, not expected outputs:
// File: src/maker/OracleMaker.sol : OracleMaker.deposit() #1
175: function deposit(uint256 amountXCD) external onlyWhitelistLp returns (uint256) {
// File: src/maker/OracleMaker.sol : OracleMaker.withdraw() #2
228: function withdraw(uint256 shares) external onlyWhitelistLp returns (uint256) {
and the value received is based on the Pyth oracle.
Tool used
Manual Review
Recommendation
Provide slippage parameters
Discussion
sherlock-admin3
2 comment(s) were left on this issue during the judging contest.
santipu_ commented:
Medium
takarez commented:
no need of slippage.
lnxrp
- Invalid, known issue
- We will add protection in the future to both makers (link)(link) against volatility, but it is consider non-urgent since deposit/withdraw is whitelisted at the beginning
lnxrp
Clarification: we knew there is currently not enough protection as commented in the two links above
IllIllI000
Escalate
As is pointed out here, the hierarchy says this should be valid, and if that escalation is right about the rule, this one should be valid because it's a loss of funds to the LP without any way to avoid it. See also this
sherlock-admin2
Escalate
As is pointed out here, the hierarchy says this should be valid, and if that escalation is right about the rule, this one should be valid because it's a loss of funds to the LP without any way to avoid it. See also this
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.
nevillehuang
I believe this issue should remain invalid given it is a known issue based on code comments within contract, unless I have misinterpreted what the hierachy of truth is meant to represent.
WangSecurity
I believe this should remain invalid. The hierarchy of truth is used when there's a conflicting information between the README, rules or comments, which is not the case when we talk about intended design/known issues. Hence, planning to reject the escalation and leave the issue as it is.
Evert0x
Result: Invalid Has Duplicates
sherlock-admin4
Escalations have been resolved successfully!
Escalation status:
- IllIllI000: rejected
Evert0x
#121 and duplicates will become Medium. The hierachy of truth will be interpreted as stated here https://github.com/sherlock-audit/2024-02-perpetual-judging/issues/65#issuecomment-2077966086.
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 deposit and withdraw functions do not accept slippage parameters, so users cannot protect themselves against price changes between transaction submission and execution.
Impact
A user could lose up to half of their expected collateral if a flash crash occurs between transaction submission and mining, as the price may recover before the user can react.
What the attacker needed
Whitelisted LP; flash crash during transaction
The fix
The protocol should add slippage parameters to the deposit and withdraw functions to allow users to specify a minimum acceptable amount.
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 put money into a shared pool (like a savings account), you get shares. Later, you redeem shares for money. If the pool's value changes quickly, you might get less than you expected. This report says the pool's deposit and withdraw functions don't let you set a minimum amount you'll accept, so you could lose money if the price moves suddenly.
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.