Division-by-zero in long-leg collateral requirement can block solvency checks and dispatchFrom (liquidation/force-exercise) for tickSpacing==1 pools
For pools with tickSpacing equal to one, a long position with a one-tick-wide leg evaluated at a tick equal to its strike causes a division-by-zero revert in the risk engine's margin calculation. Because dispatchFrom always includes the current tick, liquidation, force-exercise and settlement actions can hard-revert when the current tick equals the strike, potentially blocking third-party resolution at those prices.
Submitted by niffylord, also found by 0xnija, Agontuk, Blackdruid, Diavolo, edoscoba, Ituba, legat, LimeiBBQ, and VulSight
For pools with tickSpacing == 1, a 1-tick-wide long leg (width == 1) evaluated at atTick == strike triggers a division-by-zero revert inside RiskEngine margin computation. Because PanopticPool.dispatchFrom(...) always includes currentTick in its tick set, any liquidation/force-exercise/settle action that hits currentTick == strike can hard-revert, potentially blocking third-party resolution actions at specific prices.
Exploit narrative (attack steps)
Assumptions:
- Target pool has
tickSpacing == 1. - Attacker can obtain/hold a long position with a 1-tick-wide leg and strike
T.
Steps:
- Ensure the position exists with
width == 1,tickSpacing == 1,strike == T. - When
dispatchFrom(...)evaluates solvency at ticks includingcurrentTick, andcurrentTick == T, margin evaluation calls intoRiskEngineand reverts (division-by-zero), blocking the action.
Affected components/code references (GitHub links)
- Division-by-zero source (long-leg branch):
RiskEngine.solL1508 andRiskEngine.solL1541 dispatchFromincludescurrentTickin tick set:PanopticPool.solL1360 andPanopticPool.solL1392
Proof of Concept
This PoC uses the existing V3 harness and demonstrates liquidation reverting with a division-by-zero error.
Put this function inside PanopticPoolTest in: test/foundry/coreV3/PanopticPool.t.sol
Run:
FOUNDRY_PROFILE=ci_test FOUNDRY_ETH_RPC_URL=https://ethereum.publicnode.com \
forge test \
--match-path test/foundry/coreV3/PanopticPool.t.sol \
--match-test test_poc_WidthOneLongAtStrike_DivisionByZero_BlocksLiquidation
View detailed Proof of Concept
- When
tickSpacing == 1andwidth == 1, the code path setspositionWidth = tickUpper - tickLower = 1. - In the long-leg branch,
distanceFromStrike = max(positionWidth / 2, abs(atTick - strike))becomesmax(0, 0) = 0whenatTick == strike. - The subsequent computation divides by
(distanceFromStrike * expValue), which becomes a division-by-zero revert. The PoC triggers this exact state and assertsstdError.divisionErrorduring liquidation.
Recommended mitigation steps
Add a distanceFromStrike == 0 guard in the long-leg branch (e.g., clamp to 1), and/or disallow width==1 longs for tickSpacing==1 pools if that’s an acceptable constraint.
No more division-by-zero in long-leg collateral requirement.
Status: Mitigation confirmed. Full details in reports from Valves, edoscoba, and Nyx.
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 long-leg margin formula divides by a distanceFromStrike term that can be zero when the position width is one and the evaluated tick equals the strike, with no guard against that case.
Impact
Liquidation, force-exercise and settlement actions could hard-revert when the current tick equals the strike of such a position, potentially blocking third-party resolution at those prices.
What the attacker needed
Pool with tickSpacing equal to one; long position with a one-tick-wide leg; current tick equals the strike
The fix
The project added a guard so the long-leg collateral requirement no longer divides by zero, and the mitigation was confirmed.
How it was found
- Have a pool where tickSpacing equals one.
- Hold a long position with a one-tick-wide leg and strike T.
- Trigger dispatchFrom so that the current tick equals T.
- Observe the margin evaluation revert with a division-by-zero error, blocking the action.
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 calculates how much collateral a position needs by dividing by a distance value. When a position is exactly one tick wide and the current price sits exactly on its strike, that distance becomes zero, and dividing by zero makes the transaction fail. The result is that actions like liquidation cannot run at that particular price.
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.