Skip to content
Business logic Audit finding Intermediate

Quote pools are expected to have same base token and quote token but this is not enforced in swaps

S3v3ru5 Follow with g

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-08-woofi-solana-deployment-judging/issues/64

Found by

S3v3ru5, g

Summary

The missing constraint that enforces quote pools should have the same base and quote token will cause swap fees to be deducted from non-quote pools.

By design, quote pools are pools with the same base and quote token. The development team has confirmed this. All swap fees should come from quote pools.

Rust
  // record fee into account
  woopool_quote.sub_reserve(swap_fee).unwrap();
  woopool_quote.add_unclaimed_fee(swap_fee).unwrap();

Root Cause

In swap.rs:79-84, there is no constraint that enforces that the pool used as the quote pool has the same base token and quote token.

Rust
  #[account(mut,
      has_one = wooconfig,
      constraint = woopool_quote.token_mint == woopool_from.quote_token_mint,
      constraint = woopool_quote.authority == woopool_from.authority,
  )]
  woopool_quote: Box<Account<'info, WooPool>>,

This means that non-quote pools can be used as quote pools during swaps and swap fees will be deducted from these.

Rust
  // record fee into account
  woopool_quote.sub_reserve(swap_fee).unwrap();
  woopool_quote.add_unclaimed_fee(swap_fee).unwrap();

Internal pre-conditions

None

External pre-conditions

None

Attack Path

  1. Anyone can execute swaps by invoking the swap instruction and passing a non-quote pool as a woopool_quote. The constraints will allow it as long as the woopool_quote's base token is the same as the woopool_from's quote token and the pools have the same owners.

Impact

Swap fees can be deducted from non-quote pools instead of quote pools only.

PoC

No response

Mitigation

Consider adding a constraint that enforces that the quote pool is a pool with the same base and quote token.

Discussion

toprince

Need investigation here. Same with https://github.com/sherlock-audit/2024-08-woofi-solana-deployment-judging/issues/40

toprince

should be Not valid.

  1. all pools' quote_token_mint is USDC after create pool
  2. constraint = woopool_quote.token_mint == woopool_from.quote_token_mint
  3. above constraint should make sure the quote pool is USDC

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/woonetwork/WOOFi_Solana/pull/29

gjaldon

The added constraints to swap() fixes the issue.

The original report as published on Sherlock, by S3v3ru5. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is known

A high-severity business logic bug in WOOFi Swap on Solana. Sherlock made it public on 16 October 2024. Found in the 535 audit contest (finding H-2), also found by 1 other warden.

About Business logic

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

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.

More by S3v3ru5

View all

1 more disclosed report, best first.

More from WOOFi Swap on Solana

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.