Missing Uniswap V3 cardinality initialization in `StNxmOracle` leads to permanent Denial of Service
The StNxmOracle contract queries a 30-minute TWAP from a Uniswap V3 pool but does not ensure the pool's observation cardinality is sufficient, so the price function reverts. This causes a denial of service for dependent systems like Morpho markets.
0x73696d616f Follow with 0xAsen, Almanax and 6 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-11-stnxm-by-easedefi-judging/issues/899
Found by
0x73696d616f, 0xAsen, Almanax, Anas22, Sir_Shades, befree3x, hanz, khaye26, thimthor
Summary
The StNxmOracle contract calculates the price of stNXM using a 30-minute Time-Weighted Average Price (TWAP) from a Uniswap V3 pool. However, newly created Uniswap V3 pools are initialized with an observationCardinality of 1 by default, which only stores the current block's state.
Because the Oracle does not expand this cardinality during initialization, calls to OracleLibrary.consult requesting data from 1800 seconds (30 minutes) ago will inevitably fail. This causes the price() function to revert consistently, rendering the oracle unusable and bricking any dependent systems (like Morpho markets) immediately upon deployment.
Root Cause
In stNxmOracle.sol, the constructor sets the dex address but fails to call increaseObservationCardinalityNext on the Uniswap V3 pool.
By default, Uniswap V3 pools have an observationCardinality of 1. To successfully query a TWAP over a window of TWAP_PERIOD (1800 seconds), the pool must be configured to store enough historical observation slots to cover that duration given the chain's block time. Without this initialization, OracleLibrary.consult reverts when trying to interpolate a past timestamp.
Internal Pre-conditions
StNxmOracleis deployed with a reference to a Uniswap V3 pool.- The
StNxmOracleattempts to query a TWAP period of 1800 seconds (TWAP_PERIOD).
External Pre-conditions
- The linked Uniswap V3 pool has the default
observationCardinalityof 1 (or any value insufficient to cover 30 minutes of history).
Attack Path
- Deployment: The protocol deploys
StNxmOracle. - Interaction: A user or the Morpho protocol calls
stNxmOracle.price()to value collateral. - Execution:
- The function calls
OracleLibrary.consult(dex, 1800). - The library attempts to fetch the observation from 1800 seconds ago.
- The Uniswap pool checks its observation buffer. Since cardinality is 1, it cannot provide history.
- The function calls
- Failure: The transaction reverts.
- DoS: The Oracle remains unusable until an external party manually calls
increaseObservationCardinalityNexton the pool and waits for the buffer to fill.
Impact
The protocol cannot execute Oracle updates. This results in an immediate Denial of Service (DoS) for the lending integration. Morpho cannot retrieve a valid price, preventing users from borrowing and preventing liquidators from securing the protocol.
PoC
No response
Mitigation
In the StNxmOracle constructor, verify the pool's cardinality and increase it if necessary to support the 30-minute TWAP. A safe buffer is recommended (e.g., 100 slots).
constructor(address _dex, address _wNxm, address _stNxm) {
dex = IUniswapV3Pool(_dex);
wNxm = _wNxm;
stNxm = _stNxm;
startTime = block.timestamp;
+ // Increase cardinality to ensure enough history for 30m TWAP
+ // 100 slots is usually sufficient for 30 mins on Mainnet (12s blocks)
+ // But safer to go higher or calculate exact needs.
+ dex.increaseObservationCardinalityNext(100);
}
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/EaseDeFi/stNXM-Contracts/commit/98c005807c5f74d61de7280d572c4aac7ba2f8cb
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 StNxmOracle constructor does not call increaseObservationCardinalityNext on the Uniswap V3 pool, leaving the default cardinality of 1, which is insufficient for a 30-minute TWAP.
Impact
The oracle is unusable, causing an immediate denial of service for the lending integration: Morpho cannot retrieve a valid price, preventing borrowing and liquidations.
What the attacker needed
StNxmOracle deployed with a Uniswap V3 pool; Pool cardinality insufficient for 30 minutes
The fix
The protocol team fixed this issue by increasing the pool's observation cardinality in the constructor.
How it was found
- Deploy StNxmOracle with a reference to a Uniswap V3 pool.
- A user or the Morpho protocol calls stNxmOracle.price().
- The function calls OracleLibrary.consult(dex, 1800).
- The library tries to fetch the observation from 1800 seconds ago.
- The Uniswap pool cannot provide history because cardinality is 1, so the transaction reverts.
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.
A Uniswap V3 pool stores price history in a limited buffer. By default, it only keeps the latest observation, so asking for a price from 30 minutes ago fails. The oracle contract never increased that buffer, so its price function always reverts, breaking anything that relies on it.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.