Skip to content
Access control Audit finding Intermediate

Attackers can drain the protocol tokens

The contract does not verify that the pool address supplied by a maker is a legitimate Uniswap V3 pool. An attacker can pass a malicious contract as the pool, which then calls back with arbitrary amounts in the mint callback, causing the protocol to transfer all its token balances to the attacker.

0x37 Follow with 0xBanku, 0xnija and 19 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-09-ammplify-judging/issues/566

Found by

0x37, 0xBanku, 0xnija, 0xpinkman, EtherEngineer, KiroBrejka, Meta_Bug, P00, SanketKogekar, TheSavageTeddy, XDZIBEC, Ziusz, anonymousjoe, blockace, har0507, m4ze, neeloy, panprog, serenity1337, t.aksoy, vivekd, vtim

Summary

There is no verification of the pool address passed by makers. This allows users to pass malicious pool address to the newMaker() function, and steal all the tokens present in the contract via calling the uniswapV3MintCallback function. This causes all the fees (of non-compound makers, JIT Penalties and the xCFees yCFees to be stolen).

Root Cause

Not verifying that the pool is a valid uniswap v3 pool, allows the user to pass any address as the pool address. Then the malicious contract can call back the maker contract with huge negative values as the parameters in the uniswapV3MintCallback.

Internal Pre-conditions

None.

External Pre-conditions

None.

Attack Path

Solidity
        require(liq >= MIN_MAKER_LIQUIDITY, DeMinimusMaker(liq));
        PoolInfo memory pInfo = PoolLib.getPoolInfo(poolAddr);
        (Asset storage asset, uint256 assetId) = AssetLib.newMaker(
            recipient,
            pInfo,
            lowTick,
            highTick,
            liq,
            isCompounding
        );
        Data memory data = DataImpl.make(pInfo, asset, minSqrtPriceX96, maxSqrtPriceX96, liq);
        // This fills in the nodes in the asset.
        WalkerLib.modify(pInfo, lowTick, highTick, data);
        // Settle balances.
        address[] memory tokens = pInfo.tokens();
        int256[] memory balances = new int256[](2);
        balances[0] = data.xBalance;
        balances[1] = data.yBalance;
        RFTLib.settle(msg.sender, tokens, balances, rftData);
        PoolWalker.settle(pInfo, lowTick, highTick, data);  // <= calls the PoolWalker.settle => PoolWalker.updateLiq => PoolLib.mint()
        return assetId;
    }

https://github.com/sherlock-audit/2025-09-ammplify/blob/main/Ammplify/src/facets/Maker.sol#L31-L52

  1. User calls the newMaker() function with a malicious contract address (that he created)
  2. The initial pool calls such as the ones in PoolLib.getPoolInfo() will return normal values
  3. Further the position is created, and the nodes updated.
  4. During the RFTLib.settle, the user pays a small amount to the protocol. (as calculated by the tree traversal)
  5. In the PoolWalker.settle function, the contract walks to the dirty nodes and calls the updateLiq function which calls the PoolLib.mint() function
  6. This adds the malicious pool address in the POOL_GUARD_SLOT, and calls the mint() function of the pool
Solidity
    function mint(
        address pool,
        int24 tickLower,
        int24 tickUpper,
        uint128 liquidity
    ) internal returns (uint256 amount0, uint256 amount1) {
        POOL_GUARD_SLOT.asAddress().tstore(pool);
        (amount0, amount1) = IUniswapV3Pool(pool).mint(address(this), tickLower, tickUpper, liquidity, "");
        POOL_GUARD_SLOT.asAddress().tstore(address(0));
    }
  1. The user's malicious pool can now give the entire balance of the protocol as the parameters in the uniswapV3MintCallback function
  2. This will cause the protocol to transfer the entire balance to the pool contract.
Solidity
    function uniswapV3MintCallback(uint256 amount0Owed, uint256 amount1Owed, bytes calldata) external {
        address activeMint = PoolLib.poolGuard();
        require(msg.sender == activeMint, UnauthorizedMint(activeMint, msg.sender));
        PoolInfo memory pInfo = PoolLib.getPoolInfo(activeMint);
        TransferHelper.safeTransfer(pInfo.token0, activeMint, amount0Owed);
        TransferHelper.safeTransfer(pInfo.token1, activeMint, amount1Owed);
    }

https://github.com/sherlock-audit/2025-09-ammplify/blob/main/Ammplify/src/facets/Pool.sol#L16-L22

Impact

Theft of user fees, JIT penalties and in some cases their principal liquidity tokens too. (In certain cases, the liquidity is not instantly minted so it remains in the contract which can now be stolen).

PoC

No response

Mitigation

Verify that the inputted pool address is a valid uniswap v3 pool created by uniswap v3 factory.

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/itos-finance/Ammplify/pull/43

The original report as published on Sherlock, by 0x37. 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 contract fails to verify that the provided pool address is a legitimate Uniswap V3 pool created by the official factory, allowing an attacker to supply a malicious contract that exploits the mint callback to withdraw arbitrary amounts.

Impact

The attacker can steal all fees (from non-compound makers, JIT penalties, and xCFees/yCFees) and in some cases principal liquidity tokens that remain in the contract.

What the attacker needed

Ability to call newMaker(); attacker deploys a malicious contract

The fix

The protocol team fixed this issue by verifying that the inputted pool address is a valid Uniswap V3 pool created by the Uniswap V3 factory.

How it was found

  1. User calls the newMaker() function with a malicious contract address that they created.
  2. The initial pool calls such as the ones in PoolLib.getPoolInfo() return normal values.
  3. The position is created and the nodes are updated.
  4. During RFTLib.settle, the user pays a small amount to the protocol.
  5. In PoolWalker.settle, the contract walks to dirty nodes and calls updateLiq, which calls PoolLib.mint().
  6. PoolLib.mint() stores the malicious pool address in POOL_GUARD_SLOT and calls mint() on the malicious pool.

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.

When you create a new maker position, you tell the contract which Uniswap pool to use. The contract trusts that address without checking it is a real pool. An attacker can give their own contract address instead, and that contract can ask the protocol to send it any amount of tokens, draining the protocol's funds.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by 0x37

View all

79 more disclosed reports, best first.

More from Ammplify

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.