Reproduced Exploit
Polynomial Protocol — short positions can be burned while still holding collateral
1. ShortToken.adjustPosition writes the new shortAmount, then burns the position's ERC721 whenever shortAmount == 0. 2. It never checks collateralAmount. A position can therefore be burned while it still records — and ShortCollateral still physically holds — collateral.
Chain
Other
Category
logic
Date
Mar 2023
Source
AuditVault
EVM Playground
Source-level debugger — step opcodes and Solidity in sync
The attack is replayed in an in-browser EVM preloaded with the exact dumped fork state. The execution tree shows every call; step by Solidity line or by opcode across all depths — source, Stack, Memory, Storage, Transient storage and Return value stay in sync. Click a tree node, opcode, or source line to jump. No backend, no live RPC.
Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 20226-h-03-short-positions-can-be-burned-while-holding-collateral. Standalone Foundry PoC and full write-up: 20226-h-03-short-positions-can-be-burned-while-holding-collateral_exp in the
evm-hack-registrymirror.
Vulnerability classes: vuln/logic/wrong-condition · vuln/loss-of-funds/locked-funds · vuln/nft/burn-with-residual-state
Reproduction: a self-contained Foundry PoC that compiles & runs in an isolated project with only
forge-std— no fork, no RPC, noanvil_state. Full trace: output.txt. PoC: test/20226-h-03-short-positions-can-be-burned-while-holding-collateral_exp.sol.
Key info#
| Impact | HIGH — a short position's ERC721 is burned the instant its short size reaches 0, even with collateral remaining; that collateral becomes permanently locked because it can only be paid out to the (now non-existent) position owner |
| Protocol | Polynomial Protocol — options/perps (short-position core) |
| Vulnerable code | ShortToken.adjustPosition — if (position.shortAmount == 0) { _burn(positionId); } (no collateralAmount == 0 check) |
| Bug class | Wrong condition: state (collateral) survives an entity (the position NFT) that is destroyed too eagerly |
| Finding | Code4rena — Polynomial Protocol, 2023-03 · #20226 · reporter Bauer |
| Report | code4rena.com/reports/2023-03-polynomial |
| Source | AuditVault |
| Status | Audit finding — confirmed by the sponsor, judged HIGH (not exploited on-chain). Reproduced here as a standalone local PoC. |
| Compiler | ^0.8.24 (PoC) |
This is an audit finding, not a historical on-chain incident. The upstream
Code4rena source repo has been taken down, so the reduced PoC preserves the
vulnerable adjustPosition burn logic verbatim from the finding and the merged
contest report, and models a minimal Exchange / ShortToken / ShortCollateral so
the "collateral locked" harm becomes a mechanically-checkable state.
TL;DR#
ShortToken.adjustPositionwrites the newshortAmount, then burns the position's ERC721 whenevershortAmount == 0.- It never checks
collateralAmount. A position can therefore be burned while it still records — andShortCollateralstill physically holds — collateral. - Collateral is only ever returned via
ShortCollateral.sendCollateral, which resolves the recipient throughshortToken.ownerOf(positionId). After the burn that call revertsNOT_MINTED, so the collateral can never be paid out. - Three realistic triggers (per the finding): a user reduces a short to 0 while
keeping collateral; an attacker fully liquidates a short with residual
collateral; or an attacker frontruns a
closeTradewith a liquidation. - In the PoC a user opens a
1e18short backed by1e15sUSD, then fully closes it while withdrawing no collateral. The position is burned; the1e15collateral stays inShortCollateralwith no owner to receive it — a permanent loss.
The vulnerable code#
ShortToken.adjustPosition (verbatim burn logic):
position.collateralAmount = collateralAmount;
position.shortAmount = shortAmount;
if (position.shortAmount == 0) { // @> burns even when collateralAmount != 0
_burn(positionId);
}
The only collateral-return path resolves the recipient via ownerOf, which
reverts once the position is burned:
function sendCollateral(uint256 positionId, uint256 amount) external onlyExchange {
UserCollateral storage uc = userCollaterals[positionId];
uc.amount -= amount;
address user = shortToken.ownerOf(positionId); // reverts NOT_MINTED after burn
ERC20(uc.collateral).safeTransfer(user, amount);
}
Root cause#
Burning the position NFT is treated as equivalent to "the short is closed",
but the NFT is also the sole key to the collateral held for that position.
Destroying it while collateralAmount > 0 orphans real assets: the accounting
still says the collateral exists, ShortCollateral still holds the tokens, but
there is no owner the protocol can pay it to. The burn condition must also
require collateralAmount == 0.
Preconditions#
- A position exists with
collateralAmount > 0. - Any operation drives
shortAmountto 0 without first zeroing the collateral (a partial-close that keeps collateral, or a full liquidation that leaves a residual). All are permissionless / normal-flow.
Attack walkthrough#
From output.txt:
- Victim deposits
1e15sUSD collateral and opens a1e18short;ShortTokenmints the position andShortCollateraltakes custody of the collateral. - Victim fully closes the short (
closeShort(id, 1e18, 0)) — reducingshortAmountto 0 but withdrawing 0 collateral, so the position keeps its1e15. adjustPositionsetsshortAmount = 0and, because of that,_burns the position — withcollateralAmountstill1e15.- HARM:
ownerOf(id)now revertsNOT_MINTED; the1e15collateral is still recorded on the position and still sitting inShortCollateral, but everysendCollateralcall reverts (owner lookup fails). The collateral is permanently locked; the victim recovered nothing.
Diagrams#
Impact#
A user (or victim of a liquidation/frontrun) permanently loses whatever
collateral remains on a position that is closed to shortAmount == 0. The loss
is exactly the residual collateral: in the PoC, 1e15 sUSD, unrecoverable by
anyone. The finding was confirmed by the sponsor and judged HIGH.
Remediation#
Guard the burn on collateral too:
- if (position.shortAmount == 0) {
+ if (position.shortAmount == 0 && position.collateralAmount == 0) {
_burn(positionId);
}
How to reproduce#
cd ~/RustroverProjects/audits/evm-hack-registry/20226-h-03-short-positions-can-be-burned-while-holding-collateral_exp
forge test -vvv
# Fully local — no fork, no RPC, no anvil_state required.
# Expected: test_burnLocksCollateral PASSES (position burned, collateral stuck,
# every recovery path reverts NOT_MINTED).
PoC source: test/20226-h-03-short-positions-can-be-burned-while-holding-collateral_exp.sol
— drives the verbatim vulnerable adjustPosition burn and re-asserts the lock.
Note: token magnitudes, the 1:1 collateral model, and the minimal Exchange/ShortCollateral plumbing are reduced-model assumptions (the real Polynomial system is out of scope); the vulnerable burn condition and the "burned position ⇒ collateral unrecoverable" mechanism are faithful.
Sources#
- AuditVault finding: 20226-h-03-short-positions-can-be-burned-while-holding-collateral.md
- Contest report: Code4rena — Polynomial Protocol (2023-03)
- Reduced-source provenance: vulnerable
ShortToken.adjustPositionburn logic reconstructed verbatim from the AuditVault finding and the merged contest reportcode-423n4/2023-03-polynomial-findings@main(report.md,## [07]adjustPosition body). The original contest source repocode-423n4/2023-03-polynomialhas been taken down.
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 20226-h-03-short-positions-can-be-burned-while-holding-collateral_exp (evm-hack-registry mirror).
- AuditVault finding: 20226-h-03-short-positions-can-be-burned-while-holding-collateral.
Alerts & third-party analyses
These dashboards index community alerts tweets, post-mortems, and independent write-ups. Reach them through the protocol name above to cross-check this reproduction against other analyses.