Critical Logic Inversion in Price Guard Allows Flash-Loan Manipulation of Liquidity Operations
The price guard in the liquidity manager inverted its history check and failed open on TWAP errors, so it returned the untrusted spot price instead of the time-weighted average. An attacker could create a new pool, manipulate its price with a flash loan, and have the protocol mint or convert at that inflated price, draining assets.
Submitted by prazzix86, also found by ayazwx, jkk812812, M4v3r1ck, and Nyx
autonolas-tokenomics/../contracts/pol/LiquidityManagerCore.sol #L1104-L1116
The checkPoolAndGetCenterPrice function in LiquidityManagerCore.sol is intended to be a security gate that prevents the protocol from interacting with Uniswap V3 pools at manipulated “instant” prices. It is designed to verify the slot0 price against a 30-minute Time-Weighted Average Price (TWAP).
However, two critical flaws in the implementation render this protection completely ineffective:
1. Logic Inversion in History Check (Mature Pools) The contract uses the following check to decide whether to bypass the TWAP verification:
1104: if (oldestTimestamp + SECONDS_AGO < block.timestamp) {
1105: return centerSqrtPriceX96;
1106: }
In Uniswap V3, oldestTimestamp is the timestamp of the earliest recorded price point in the observation buffer.
If the pool is mature (has ≥ 30 mins of history), the condition oldestTimestamp + 1800 < block.timestamp is TRUE. The Result: The function returns the untrusted slot0 price immediately, bypassing the TWAP check for exactly the pools that have sufficient data to be checked.
2. Fail-Open Architecture on Verification Failure (New Pools) If the pool is new (history < 30 mins), the code proceeds to call getTwapFromOracle. This call will typically revert because the Uniswap observe function requires data reaching back the full SECONDS_AGO period.
1111: (bool success, bytes memory returnData) = address(this).staticcall(payload);
1112:
1113: // If the call has failed - observe was not successful...
1114: if (!success) {
1115: return centerSqrtPriceX96;
1116: }
Instead of reverting (Fail-Closed), the protocol catches the error and returns the untrusted price. This creates a trivial bypass: an attacker can create a new pool, manipulate its price, and the protocol will use that manipulated price because the “security check” failed to execute.
Step-by-Step Exploit Scenario
- Preparation: Attacker identifies a liquidity operation (e.g., ConvertedToV3).
- Manipulation: Attacker creates a fresh Uniswap V3 pool for OLAS / SHITCOIN.
- Flash Loan: Attacker uses a flash loan to buy OLAS in this new pool, pushing the slot0 price to 100x the fair market value.
- Protocol Trigger: Attacker triggers the protocol to provide liquidity to this pool.
Bypass:
- checkPoolAndGetCenterPrice is called.
- The pool is new, so it tries getTwapFromOracle. observe([1800, 0]) reverts because the pool is only seconds old.
- The protocol catches the revert and returns the 100x manipulated slot0 price. Profit: The protocol mints a position or converts tokens based on the 100x price, allowing the attacker to effectively drain OLAS from the protocol in exchange for worthless tokens.
Impact
This is a Critical severity issue as it breaks the primary security assumption for price safety in the Protocol-Owned Liquidity (POL) module. It allows for the total drainage of assets committed to V3 liquidity operations via standard flash-loan price manipulation.
Recommended mitigation steps
The protocol should adopt a Fail-Closed security model and correct the history logic:
- if (oldestTimestamp + SECONDS_AGO < block.timestamp) {
- return centerSqrtPriceX96;
- }
+ // Ensure the pool is mature enough to have TWAP data
+ if (oldestTimestamp + SECONDS_AGO > block.timestamp) {
+ revert PoolTooNew();
+ }
uint256 twapPrice;
bytes memory payload = abi.encodeCall(this.getTwapFromOracle, (pool));
(bool success, bytes memory returnData) = address(this).staticcall(payload);
- if (!success) {
- return centerSqrtPriceX96;
- }
+ require(success, "TWAP check failed");
Proof of Concept
View detailed Proof of Concept
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 history condition was inverted so mature pools bypassed the TWAP check, and the TWAP call failure was handled by returning the untrusted spot price instead of reverting.
Impact
The protocol could mint a position or convert tokens at the manipulated price, allowing the attacker to drain OLAS from the protocol in exchange for worthless tokens.
What the attacker needed
Ability to create a Uniswap V3 pool; flash loan access; protocol liquidity operation triggered
The fix
The protocol should adopt a fail-closed model: revert when the pool is too new and require the TWAP call to succeed instead of returning the spot price.
How it was found
- Identify a liquidity operation such as ConvertedToV3.
- Create a fresh Uniswap V3 pool for OLAS and a worthless token.
- Use a flash loan to buy OLAS in the new pool and push the spot price to 100x fair value.
- Trigger the protocol to provide liquidity to that pool.
- The protocol calls the price guard, the TWAP observation reverts because the pool is new, and the guard returns the manipulated spot price.
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 smart contract that manages liquidity tried to check that a pool's current price was not manipulated by comparing it to a long-term average price. Two mistakes meant the check was skipped for mature pools and also skipped when the average could not be calculated for new pools. An attacker could therefore create a new pool, push its price up with a temporary loan, and trick the protocol into trading at that fake price.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.