Uniswap Pool price can be manipulated so stNXM adds liquidity to a super imbalanced pool and loses funds
The stNXM contract adds liquidity to a Uniswap pool without any slippage protection, so an attacker can front-run the initialisation and move the pool price to an extreme tick. The liquidity is then added entirely in wNXM at a worthless price, and the attacker can swap a tiny amount of stNXM to drain all the wNXM.
0x73696d616f Follow with 0xc0ffEE, 0xeix and 29 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-11-stnxm-by-easedefi-judging/issues/457
Found by
0x73696d616f, 0xc0ffEE, 0xeix, 0xlucky, 0xpoison, Abba.eth, Bluedragon, BoyD, Bozwkd, Ibukun, Orhukl, Polaris_2, Protokol, SoarinSkySagar, Vesko210, Vigilia-Aethereum, akolade, blockace, dee_bug, farismaulana, gkrastenov, hanz, ivxylo, kowolski, makarov, ni8mare, oxwhite, shieldrey, theboiledcorn, theholymarvycodes, typicalHuman, werulez99
Summary
stNXM::initializeExternals() adds liquidity without slippage checks, so it may add to an extremely unbalanced pool and get all funds stolen.
An attacker can do this by frontrunning the stNXM::initializeExternals() call and swapping in the dex to move the price to the lowest possible, so the tick becomes -887272, then liquidity is added in the full range at this tick, which adds the full wNXM amount to the dex, and 0 stNXM.
After this, the attacker can swap just a bit of stNXM, such as 0.01 ether, and steal the whole wNXM` from the DEX.
The attacker can even spam this for no cost to make sure it goes through, as soon as it detects the new dex created, which emits and event.
Root Cause
In stNXM.sol:120, there is no slippage protection when minting.
Internal Pre-conditions
None
External Pre-conditions
None
Attack Path
- Admin creates dex and initializes tick to price 1.
- Attacker pushes tick to -887270 with a null swap, frontrunning the admin.
- Admin calls
stNXM::initializeExternals(), adding liquidity to the unbalanced pool, which adds onlywNXM. - Attacker gets all
wNXMfrom the pool by swapping only somestNXMthat they got from the swap contract or fromstNXM::deposit()itself.
Impact
All wNXM in the dex is stolen.
PoC
Add this test to stNXM.t.sol:
function test_POC_swap_steal() public {
vm.startPrank(address(stNxmSwap));
stNxm.approve(address(swapRouter), 0.01 ether);
ISwapRouter.ExactInputSingleParams memory params = ISwapRouter.ExactInputSingleParams(
address(stNxm), address(wNxm), 500, address(stNxmSwap), 1000000000000000, 0.01 ether, 0, 0
);
swapRouter.exactInputSingle(params);
vm.stopPrank();
}
In the setup function, add the following after the line IUniswapV3Pool(dex).initialize(79228162514264337593543950336);:
vm.startPrank(address(this));
wNxm.approve(address(swapRouter), 1 ether);
dex.swap(
address(this),
true,
int256(1 ether),
4295128740,
abi.encode("")
);
vm.stopPrank();
Add the swap function to the UniswapV3Pool.sol interface file:
interface IUniswapV3Pool is IUniswapV3PoolState {
function swap(
address recipient,
bool zeroForOne,
int256 amountSpecified,
uint160 sqrtPriceLimitX96,
bytes calldata data
) external returns (int256 amount0, int256 amount1);
}
It shows the attacker stealing all the wNXM.
Mitigation
Swap to place the correct price in the pool before adding liquidity to the dex.
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/EaseDeFi/stNXM-Contracts/commit/0e3f06d7e23be25e278db034560423d77ba040f0
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
Likely the liquidity-adding function lacks a minimum-output or price-bound check, allowing the pool price to be manipulated before the deposit.
Impact
All wNXM in the dex could be stolen by the attacker.
What the attacker needed
Attacker can front-run the initialisation transaction; dex is created and initialised
The fix
The protocol team fixed this issue by swapping to place the correct price in the pool before adding liquidity.
How it was found
- Admin creates the dex and initialises the tick to price 1.
- Attacker front-runs the admin and pushes the tick to -887270 with a null swap.
- Admin calls initializeExternals(), adding liquidity to the unbalanced pool, which adds only wNXM.
- Attacker swaps a small amount of stNXM to take all wNXM from the 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 a contract puts money into a trading pool, it should check that the price is fair. Here it did not, so someone could change the price just before the deposit and make the contract put in only one token at a terrible rate. The attacker then bought that token back very cheaply and took the funds.
What is Race condition?
Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.