Skip to content
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

StabilizerNode Is Vulnerable To Sandwich Attacks #223

Closed
code423n4 opened this issue Dec 1, 2021 · 2 comments
Closed

StabilizerNode Is Vulnerable To Sandwich Attacks #223

code423n4 opened this issue Dec 1, 2021 · 2 comments
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate This issue or pull request already exists

Comments

@code423n4
Copy link
Contributor

Handle

leastwood

Vulnerability details

Impact

The permissionless stabilize function in StabilizerNode is called to correct deviations in the Malt token price. When the price of Malt has appreciated above its peg, the function simply distributes rewards to LP token holders, effectively diluting the total Malt token supply. As the _distributeSupply function interacts with a Uniswap pool without performing slippage checks, an attacker can call this function and launch a sandwich attack in combination with a flash loan to steal funds.

A malicious user is potentially able to steal rewards that would otherwise be distributed to the protocol's users. As such, this issue should be considered high risk as this results in loss of funds.

Proof of Concept

Consider the following scenario:

  • An attacker flashloans and buys rewards tokens from the uniswap pool.
  • The attacks calls the stabilize function in StabilizerNode.
  • The StabilizerNode contract buys rewards tokens at an inflated price.
  • The attacker sells their rewards tokens and pays back their flashloan.

As shown above, attackers are able to siphon funds from users overtime.

https://github.com/code-423n4/2021-11-malt/blob/main/src/contracts/StabilizerNode.sol#L236
https://github.com/code-423n4/2021-11-malt/blob/main/src/contracts/DexHandlers/UniswapHandler.sol#L160-L183

Tools Used

Manual code review
Referenced Mochi review.

Recommended Mitigation Steps

Consider performing slippage checks within the _distributeSupply function. This can be done by simply performing a lower bounds check on the output amount received when exchanging Malt tokens for rewards tokens.

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Dec 1, 2021
code423n4 added a commit that referenced this issue Dec 1, 2021
@0xScotch 0xScotch added the duplicate This issue or pull request already exists label Dec 8, 2021
@0xScotch
Copy link
Collaborator

0xScotch commented Dec 8, 2021

#56

@0xScotch 0xScotch closed this as completed Dec 8, 2021
@GalloDaSballo
Copy link
Collaborator

Duplicate of #56

@GalloDaSballo GalloDaSballo marked this as a duplicate of #56 Jan 23, 2022
@GalloDaSballo GalloDaSballo added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels Jan 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants