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

Front-running vulnerability in pool price setting function #52

Open
howlbot-integration bot opened this issue Sep 16, 2024 · 5 comments
Open

Front-running vulnerability in pool price setting function #52

howlbot-integration bot opened this issue Sep 16, 2024 · 5 comments
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue grade-b primary issue Highest quality submission among a set of duplicates Q-12 QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax 🤖_primary AI based primary recommendation 🤖_18_group AI based duplicate group recommendation sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons sufficient quality report This report is of sufficient quality

Comments

@howlbot-integration
Copy link

Lines of code

https://github.com/code-423n4/2024-08-superposition/blob/4528c9d2dbe1550d2660dac903a8246076044905/pkg/seawater/src/lib.rs#L1089

Vulnerability details

The SeawaterAMM contract contains a function setSqrtPriceFF4DB98C() that allows the admin to change the price of a pool. However, this function is vulnerable to front-running attacks, allowing malicious actors to profit from the price change. The core issue lies in the atomic nature of the price change. Once an admin submits a transaction to change the price, this intention becomes visible in the mempool before it's executed. This window of visibility allows attackers to craft and submit their own transactions that will be executed before the price change, effectively allowing them to trade with foreknowledge of the future price.

Impact

Direct financial exploitation:

  • An attacker can monitor the mempool for pending price change transactions.
  • Upon detecting an impending price increase, the attacker can quickly buy tokens at the current lower price.
  • After the price change is executed, the attacker can immediately sell the tokens at the new, higher price for a guaranteed profit.

Proof of Concept

  1. Alice, an attacker, monitors the mempool for calls to setSqrtPriceFF4DB98C().
  2. Alice sees a transaction that will increase the price of TokenA in a specific pool.
  3. Alice quickly submits a transaction to buy TokenA at the current (lower) price.
  4. The price change transaction is executed, increasing the value of TokenA.
  5. Alice immediately sells her TokenA for a profit.

Tools Used

Manual review

Recommended Mitigation Steps

Ensure that the pool is not enabled before changing the price.

Assessed type

Other

@howlbot-integration howlbot-integration bot added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value 🤖_18_group AI based duplicate group recommendation 🤖_primary AI based primary recommendation bug Something isn't working primary issue Highest quality submission among a set of duplicates sufficient quality report This report is of sufficient quality labels Sep 16, 2024
howlbot-integration bot added a commit that referenced this issue Sep 16, 2024
@af-afk af-afk added the sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons label Sep 16, 2024
@af-afk
Copy link

af-afk commented Sep 16, 2024

We're not going to resolve this because this function will be used by the DAO in the event that a price becomes stuck, or in a programmatic context (maybe the setting of odds for example).

@alex-ppg
Copy link

The submission states that a direct price adjustment via an administrative action might be insecure to perform and may ultimately be exploited, however, the issue relies on the administrator making a mistake (i.e. updating the square root price without pausing the pool beforehand).

While restrictions might be imposed on when the function can be invoked, it remains an administrative function that we expect the Sponsor to responsibly utilize per the relevant SC verdicts rendering this submission to be a QA recommendation.

@c4-judge
Copy link
Contributor

alex-ppg changed the severity to QA (Quality Assurance)

@c4-judge c4-judge added downgraded by judge Judge downgraded the risk level of this issue QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Sep 23, 2024
@c4-judge
Copy link
Contributor

alex-ppg marked the issue as grade-c

@c4-judge c4-judge added grade-c unsatisfactory does not satisfy C4 submission criteria; not eligible for awards labels Sep 23, 2024
@c4-judge c4-judge reopened this Oct 7, 2024
@c4-judge
Copy link
Contributor

c4-judge commented Oct 7, 2024

alex-ppg marked the issue as grade-b

@c4-judge c4-judge added grade-b and removed grade-c unsatisfactory does not satisfy C4 submission criteria; not eligible for awards labels Oct 7, 2024
@C4-Staff C4-Staff added the Q-12 label Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue grade-b primary issue Highest quality submission among a set of duplicates Q-12 QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax 🤖_primary AI based primary recommendation 🤖_18_group AI based duplicate group recommendation sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons sufficient quality report This report is of sufficient quality
Projects
None yet
Development

No branches or pull requests

4 participants