PLPs can withdraw assets needed by long positions, temporarily locking buyers
Liquidity providers could withdraw all available assets from a collateral contract, leaving insufficient liquidity for long positions to be closed. This could trap long holders in their positions and cause losses if the market moved against them.
Submitted by Henri
CollateralTracker.sol L651
Summary
LPs can withdraw all available liquidity from a collateral contract, making it impossible for long positions to be closed; neither through burnOptions nor forceExercise.
Finding description
The maxWithdraw function allows LPs to withdraw up to s_depositedAssets - 1:
function maxWithdraw(address owner) public view returns (uint256 maxAssets) {
uint256 depositedAssets = s_depositedAssets;
unchecked {
uint256 available = depositedAssets > 0 ? depositedAssets - 1 : 0;
uint256 balance = convertToAssets(balanceOf[owner]);
return panopticPool().numberOfLegs(owner) == 0 ? Math.min(available, balance) : 0;
}
}
When a long position is created, tokens are pulled from the AMM back into the Panoptic Pool. These tokens increase s_depositedAssets, but they are not reserved - LPs can freely withdraw them.
The problem occurs when an LP withdraws enough assets that there isn’t sufficient liquidity left for longs to return their borrowed amount to the AMM when closing. This is more likely to happen when shorts and long are quite unbalanced (high utilisation), then s_depositedAssets would be low and easier for a LP to deplete the pool.
forceExercise cannot really help here either:
- It can only target positions with at least one long leg, so pure short positions cannot be force-exercised to replenish the pool.
- A mixed position with a delta more short than long could be closed but only the delta would replenish the pool. It is not sure that there would be enough of these specific positions.
- This could become costly for the long to close its position.
The current workaround would be for the buyer to deposit the missing amount into the collateral contract before closing the long. This is problematic because buyers shouldn’t need extra tokens to close their own position, especially as the borrowed amount can go up to 5 times their collateral.
Impact
- Long holders cannot close their positions, leading to potential losses if the market moves against them.
- If
netLiquidityis low on a given chunk, shorts also become unable to close since they would need toforceExerciselongs.
A whale LP could exploit this by waiting for the right moment to withdraw and trap long holders in their positions.
Example:
- Bob (LP) deposits 100 ETH in
vault0 - Seller deposits 5 ETH in
vault0as collateral - Alice deposits 1 ETH in
vault0as collateral s_depositedAssets = 106ETH- Seller shorts a call of 10 ETH on chunk A
- Alice longs a call of 1 ETH on chunk A
s_depositedAssets = 106 - 10 + 1 = 97ETH- Bob withdraws 97 (+fees) ETH (all available since his
balance > s_depositedAssets) s_depositedAssets = 0ETH- Alice tries to close her long, the SPFM needs to return 1 ETH from the
positionManagerto the AMM → reverts
Proof of Concept
Add the following test to test/foundry/core/PanopticPool.t.sol:
Logs
Bound result 1
vault 0 1000000
vault 1 1000000
Seller balance - vault 0 0
Seller balance - vault 1 0
Bob balance - vault 0 0
Bob balance - vault 1 0
Alice balance - vault 0 0
Alice balance - vault 1 0
max Bob can withdraw 0
Bob balance - vault 0 - after deposit 100000000000000000000
Seller balance - vault 0 - after deposit 5000000000000000000
Alice balance - vault 0 - after deposit 1000000000000000000
vault 0 106000000000001000000
Bound result 1
Bound result 20476
Bound result 1000000000000001
currentTick 195481
tickLower 204760
tickUpper 204770
Seller short positionSize 10000000000000000000
Alice long positionSize 1000000000000000000
max Bob can withdraw 97000000000000999998
View detailed Proof of Concept
Fixes a calculation error where
creditedAssetswas being subtracted fromavailable.
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
Likely the withdrawal limit did not reserve assets needed to close long positions, so liquidity providers could withdraw funds that were effectively committed to those positions.
Impact
Long holders could be unable to close their positions, leading to potential losses if the market moves against them; shorts may also become unable to close if netLiquidity is low, and a whale LP could exploit this to trap long holders.
What the attacker needed
LP deposits liquidity; Long position exists; High utilisation or unbalanced shorts/longs
The fix
The project mitigated the issue by fixing a calculation error where creditedAssets was being subtracted from available.
How it was found
- Bob (LP) deposits 100 ETH in vault0
- Seller deposits 5 ETH in vault0 as collateral
- Alice deposits 1 ETH in vault0 as collateral
- Seller shorts a call of 10 ETH on chunk A
- Alice longs a call of 1 ETH on chunk A
- Bob withdraws all available ETH, leaving s_depositedAssets at 0
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.
In this system, people deposit assets into a shared pool. Some users borrow from that pool to open positions. The bug let depositors take out so much that borrowers could not return what they owed when closing, so their positions got stuck.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.