Skip to content
DoS Audit finding Advanced

Wide-range short legs can revert solvency checks and block liquidations ( Errors.InvalidTick )

A short option leg with a very wide tick range causes the solvency calculation to revert when the current price is inside that range, because the code computes a square-root ratio for the range width, which can exceed the supported tick domain. An attacker could create such a position and later block liquidation or collateral-withdrawal checks, leaving an insolvent account unliquidatable.

edoscoba Follow

Originally disclosed on Code4rena

Submitted by edoscoba

Finding description and impact

In RiskEngine._getRequiredCollateralSingleLegNoPartner, short legs use an “in-range interpolation” path when atTick is within [tickLower, tickUpper). That path computes: scaleFactor = Math.getSqrtRatioAtTick(tickUpper - tickLower)

However, getSqrtRatioAtTick only supports ticks within [-887_272, 887_272]. While tickLower and tickUpper themselves are validated to be within bounds, their difference can exceed 887_272 for wide ranges, because the range width is width * tickSpacing (with width up to 4095 and Uniswap v4 allowing large tickSpacing values). In that case, any solvency computation that evaluates the position while the price is in-range will revert with Errors.InvalidTick().

This is exploitable as a denial-of-service on liquidation and other solvency-gated operations:

  • An attacker can create a short position with tickUpper - tickLower > 887_272 while ensuring the current tick is initially outside the range (so the in-range branch is not executed during that check).
  • If/when the market tick later enters the range, solvency checks for that account revert deterministically.
  • Liquidation paths that require solvency evaluation can be bricked, enabling “insolvent-but-unliquidatable” accounts and increasing the chance of protocol bad debt.
  • The same revert can also DoS collateral-withdraw eligibility checks or any other path that calls riskEngine.isAccountSolvent(...) at an in-range tick.

This issue is not listed in README.md “Publicly known issues” and does not appear in 2025_12_panoptic_v12_findings.md.

Recommended mitigation steps

  • Replace getSqrtRatioAtTick(tickUpper - tickLower) with a computation that never requires an out-of-domain tick input, e.g. derive the ratio from individually valid endpoints:

    • sqrtLower = Math.getSqrtRatioAtTick(tickLower)
    • sqrtUpper = Math.getSqrtRatioAtTick(tickUpper)
    • scaleFactor = sqrtUpper * FP96 / sqrtLower (choose rounding direction to preserve conservative collateral requirements)
  • Avoid “clamping” (tickUpper - tickLower) as a primary fix unless you can prove the result remains conservative; clamping changes the intended economics and can understate requirements.

  • Optionally, add a mint-time validation that rejects short legs with tickUpper - tickLower > Constants.MAX_POOL_TICK to fail fast, but the RiskEngine-side fix should still be implemented to prevent protocol-level reverts.

Proof of Concept

A runnable PoC is included as a Foundry test: test/foundry/core/WideRangeShortInRangeSqrtRatioRevertPoC.t.sol

Run: forge test --match-contract WideRangeShortInRangeSqrtRatioRevertPoC -vvv

The PoC shows the same wide-range short leg:

  1. Returns a valid collateral requirement when evaluated out-of-range, and
  2. Reverts with Errors.InvalidTick() when evaluated at a tick inside the range (triggering the in-range interpolation branch).

View detailed Proof of Concept

Panoptic marked as informative.


The original report as published on Code4rena, by edoscoba. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 code passes the difference between the upper and lower ticks to a square-root function that only accepts ticks within a fixed bound, without checking that the difference itself is in range.

Impact

Liquidation and collateral-withdrawal checks that call the solvency function can be blocked for the affected account, potentially leaving bad debt; the report notes the project marked the issue as informative.

What the attacker needed

Ability to open a short position; market price later enters the range

The fix

The solvency calculation should derive the scale factor from the individually valid lower and upper ticks instead of their difference, and optionally reject overly wide short legs at mint time.

How it was found

  1. Create a short position whose upper tick minus lower tick exceeds the supported bound, while the current tick is outside the range.
  2. Wait until the market tick moves inside the position's range.
  3. Any solvency check for that account then reverts with an invalid-tick error.

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 checks whether an account has enough collateral by doing maths on the price range of its positions. If a position's range is extremely wide, one of those maths steps asks for a value that the library cannot compute, so the whole check crashes. That crash can stop the protocol from liquidating a risky account.

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.

More by edoscoba

View all

3 more disclosed reports, best first.

More from Panoptic: Next Core

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.