Skip to content
Business logic Audit finding Beginner

Admin can not set the pool fee since it is only set in memory

The setFee function in a Uniswap implementation contract only updates a memory copy of the pool parameters, so the new fee is never saved to storage. As a result, any custom pool fee set by the admin is ignored and only the default fee applies to swaps.

IronsideSec Follow with ZeroTrust, alexzoid and 4 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-08-flayer-judging/issues/188

Found by

Ironsidesec, ZeroTrust, alexzoid, g, h2134, tvdung94, zarkk01

Summary

The pool fee is only set in memory and not in storage so specific pool fees will not apply.

Root Cause

The pool fee is only stored in memory.

ref: UniswapImplementation:setFee()

Solidity
    // @audit poolParams is only stored in memory so the new fee is not set in permanent storage
    PoolParams memory poolParams = _poolParams[_poolId];
    poolParams.poolFee = _fee;

Internal pre-conditions

  1. Admin calls setFee() with any fee value.

External pre-conditions

None

Attack Path

None

Impact

Specific pool fees will not apply. Only the default fee will apply to swaps.

ref: UniswapImplementation::getFee()

Solidity
    // @audit poolFee will always be 0
    uint24 poolFee = _poolParams[_poolId].poolFee;
    if (poolFee != 0) {
        fee_ = poolFee;
    }

PoC

No response

Mitigation

Use storage instead of memory for poolParams in setFee().

The original report as published on Sherlock, by Ironsidesec. 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.

How it worked

Root cause

The function uses a memory variable instead of a storage reference, so the assignment does not persist.

Impact

Specific pool fees will not apply; only the default fee will apply to swaps.

What the attacker needed

Admin calls setFee()

The fix

Use storage instead of memory for poolParams in setFee().

How it was found

  1. Admin calls setFee() with a fee value.
  2. The function reads pool parameters into memory.
  3. It sets the fee on the memory copy, not storage.
  4. The new fee is not saved, so getFee() returns the default.

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.

In blockchain smart contracts, 'memory' is temporary data that disappears after a function runs, while 'storage' is permanent. The admin tried to change a fee, but the code only changed the temporary copy, so the real fee never changed. This means the fee setting had no effect.

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 IronsideSec

View all

28 more disclosed reports, best first.

More from Flayer

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.