-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stabilize()
is vulnerable to flashloan sandwich attack
#311
Comments
This bug needs to be mitigated. However, the POC example given doesn't apply as under We can add a before transfer hook on Malt that will trigger Guarding |
Proposing onlyEOA via contract size check:
|
@bitdeep I believe this has been proven wrong multiple times. In summary, you can always verify if something IS a contract. And for now you can still use the msg.sender == tx.origin check, but eventually you will not have any way of proving that something is an EOA |
From reading the code I believe that anyone can sell MALT at any time. The question that this left unsolved is how would the trader be able to get malt for a discount to then dump it for again. I think this can be merged as duplicate of #56 As such medium severity is more correct |
Handle
WatchPug
Vulnerability details
When the price of Malt is off the
lowerThreshold
andupperThreshold
,StabilizerNode.sol
will market buy/sell Malt.However, since the market sell can be triggered by anyone, and there is no slippage control, it makes it vulnerable to flashloan sandwich attack.
https://github.com/code-423n4/2021-11-malt/blob/c3a204a2c0f7c653c6c2dda9f4563fd1dc1cecf3/src/contracts/StabilizerNode.sol#L145-L174
https://github.com/code-423n4/2021-11-malt/blob/c3a204a2c0f7c653c6c2dda9f4563fd1dc1cecf3/src/contracts/StabilizerNode.sol#L211-L246
https://github.com/code-423n4/2021-11-malt/blob/c3a204a2c0f7c653c6c2dda9f4563fd1dc1cecf3/src/contracts/StabilizerNode.sol#L317-L341
POC
When the price is below
lowerThreshold
.The attacker can:
stabilize()
, the swingTrader will buy Malt at a higher price;Recommendation
Consider making
stabilize()
function only allowed to be called by an EOA to prevent flash loan sandwich attack.The text was updated successfully, but these errors were encountered: