# Ghost-Filled Orders: Detecting and Testing Atomicity Violations in Non-Custodial Prediction Markets

Crypto.world

> Non-custodial prediction markets accept and match user-signed orders off-chain, then settle them later through on-chain smart contracts. Because the on-chain state that an order depends on is not…

**arXiv**: 2609.17902

**Published**: 2026-09-15

**Authors**: Zhiyang Chen, Fan Long, Zhendong Su

## AI summary

Ghost-Filled Orders: Detecting and Testing Atomicity Violations in Non-Custodial Prediction Markets

## Overview

**Research area:** Blockchain security — specifically the security of non-custodial, blockchain-based prediction markets that combine an off-chain central limit order book with on-chain settlement. The work sits at the intersection of smart-contract security, empirical blockchain measurement, and market microstructure.

**Technical level:** Intermediate. The paper contains a formal section (definitions of transactions, orders, settlement bundles, precondition predicates, failing legs, failing latency, invalidating cost) and assumes familiarity with ERC-20 and ERC-1155 token standards, but its central argument — that matched orders can be invalidated before settlement — is understandable without the formalism.

**Scope:** An empirical and audit-based study of "ghost-filled orders" in Polymarket (1,824,926 reverted settlement transactions over a nine-month period), plus a black-box auditing procedure applied to three additional blockchain-based prediction markets.

## What This Paper Is About

Non-custodial prediction markets accept and match user-signed orders off-chain, then settle them later through on-chain smart contracts. Because the on-chain state that an order depends on is not locked during that delay, an order can be valid when matched off-chain but invalid by the time settlement executes — a time-of-check to time-of-use (TOCTOU) gap the community calls "ghost-filled" orders. The paper's goal is to explain exactly which actions can invalidate a matched order, measure how often and how profitably this happens in practice on Polymarket, and test whether other prediction markets expose the same weakness.

## Key Contributions

1. **Problem formulation.** The authors formalize ghost-filled orders as an atomicity violation in non-custodial blockchain-based prediction markets, and split the research problem into two parts: analyzing ghost-filled orders that already occurred, and auditing new prediction markets for the same flaw. They define a formal vocabulary — failing leg, responsible party, order-invalidating transaction, failing latency, invalidating cost — and a threat model in which the operator and other privileged parties are assumed benign while the adversary is an ordinary, non-privileged, financially rational user.
2. **An analysis framework of detectors and probes.** The framework first flattens the Polymarket settlement contracts and enumerates every revert guard, extracting a precondition predicate and the party responsible for falsifying it. It then replays each reverted settlement transaction to locate the failing leg (a detector) and backtracks the responsible party's transaction history to find the exact transaction that flipped the predicate from true to false (a probe). Over all 1,824,926 Polymarket reverts, the framework classifies 100% of reverts and identifies order-invalidating transactions for 96.6% of the user-controlled reverts.
3. **A quantified financial impact analysis.** Using the framework, the authors evaluate two highly suspicious scenarios in which ghost-filled orders were very likely used to avoid losses or to outcompete other market makers. They report that the responsible parties avoided a loss of over 61M USD, and that 77% of the ghost-filled order clusters are dominated by a single responsible party.
4. **A black-box auditing procedure and zero-day discoveries.** The authors develop an audit procedure and apply it to three other blockchain-based prediction markets. All three remain exploitable through the same class of invalidation, and one design enables direct attacker profit. Every finding was responsibly disclosed; one project had acknowledged the issue at the time of the study.

## Main Findings

- **Ghost-filled orders are not uniform in nature.** A substantial share exhibit patterns indicating deliberate, strategic invalidation: they concentrate in a small number of markets and responsible parties, and the invalidating transaction lands within very short timeframes (0–2 blocks) of the reverted settlement.
- **The economic effects are strongly asymmetric.** In timing-sensitive markets, reverted fills overwhelmingly avoid losses for the order owner, which is consistent with strategic invalidation of unfavorable trades rather than with accidental failure.
- **Over 61M USD in losses avoided.** Across the two highly suspicious scenarios analyzed, the responsible parties avoided a loss exceeding 61M USD.
- **Clusters are concentrated.** 77% of the ghost-filled order clusters are dominated by a single responsible party.
- **The attack surface is a taxonomy of preconditions.** The paper separates preconditions normal users cannot invalidate — access control (O1), function unpaused (O2), valid signature (O3), valid fee (O4), active order (O5), sufficient gas (O6), and non-overfilled order (O7), all attributed to the operator, the admin, or the sender — from six user-controlled preconditions: nonce (U1), ERC-20 approval (U2), ERC-1155 approval (U3), ERC-20 balance (U4), ERC-1155 balance (U5), and the ERC-1155 receiver hook (U6).
- **Invalidation requires no privileged access.** An order owner can increment the account nonce, lower an ERC-20 allowance, revoke an ERC-1155 `setApprovalForAll`, move collateral or conditional tokens out of the account, or reprogram an `onERC1155Received` hook. These are ordinary user-controlled smart contract interactions. The paper notes that the nonce mechanism was removed in Polymarket v2 (so it applies only to v1 contracts, which are no longer active), and that as of June 9, 2026 a v1 account is automatically banned if it ever increments its nonce; it likewise notes that accounts updating their account contract to add or change hook code are automatically banned, making that vector only theoretical.
- **The damage spreads beyond the invalidated order.** A single settlement transaction can bundle multiple matched orders, and on-chain execution is atomic: one invalidated order reverts the entire bundle, so otherwise valid orders in the same bundle also fail to settle. From a frontend perspective, a trade can appear matched and then disappear or be reported as failed.
- **The problem is not unique to Polymarket.** All three additional blockchain-based prediction markets tested were vulnerable to the same class of attack, and one design enables direct attacker profit.
- **Context on market size.** As of June 5, 2026, 96 prediction markets are reported to hold $480.16M in total value locked and to produce $2.709B in seven-day prediction volume.
- **The issue is acknowledged in practice.** In 2026 Polymarket publicly acknowledged the "ghost-filled" order issue and subsequently announced two urgent upgrades.

## Methodology in Plain English

The authors work in two stages.

**Stage one: read the contracts.** They flatten the Polymarket settlement contract code and inspect every settlement-related function for `revert` and `require` guards. Each guard is a place where a settlement can fail. For each guard they write down the condition that must hold (the precondition) and ask who could make that condition false — the operator, an admin, or an ordinary user.

**Stage two: replay real failures.** For each reverted settlement transaction in their nine-month window (August 12, 2025 to May 22, 2026), they replay the transaction to obtain an execution trace, decode the revert data into a selector, and match it against the guard taxonomy. This "detector" step returns the failing leg: the violated precondition plus the order that triggered it. Revert selectors attribute failures directly to most preconditions; gas exhaustion is identified by gas consumed being very close to the gas limit and not caused by an ERC-1155 receiver hook; and overfill is confirmed by checking that every order in the bundle is individually valid in the prestate and then comparing each token's cumulative fill against available balance or allowance.

Once the failing leg is known, a "probe" — one per precondition type, using predicate-specific heuristics — scans the responsible party's prior transaction history for the transaction that flipped the predicate from true to false. For the nonce case, for example, the probe finds the most recent `incrementNonce` call preceding the reverted settlement. The authors then compute two quantities per failure: failing latency (blocks between the invalidating transaction and the revert) and invalidating cost (gas used times gas price of the invalidating transaction). They explicitly develop conservative measurement rules to avoid overclaiming impact, and they separate attacker profit from market and user loss.

For the audit portion, they run a black-box procedure against three other markets: test whether a normal user can still invalidate a settlement, and determine whether doing so is economically rational — that is, whether expected gain exceeds cost.

## Why This Matters

**Impact on research.** The paper reframes a community-known operational complaint as a precise security property — an off-chain/on-chain atomicity violation — with a reusable formal vocabulary and a detection methodology. It also provides a template for auditing hybrid architectures generally, not just prediction markets: any system that matches off-chain and settles on-chain has a comparable gap.

**Real-world applications:**

- **Order-book design for decentralized exchanges.** The precondition taxonomy tells designers exactly which state a signed order depends on, and therefore which state must be locked, escrowed, or checked at match time rather than at settlement time.
- **Market-maker and trader risk assessment.** A market maker quoting against a book where matched orders can evaporate is exposed to adverse selection it cannot see in the UI. The 0–2 block latency and cluster-concentration findings give concrete signals for identifying this behavior.
- **Exchange and protocol monitoring.** The detectors can be run continuously over reverted settlement transactions to flag strategic invalidation, distinguishing it from benign settlement failures and operational mistakes.
- **Disclosure and remediation practice.** The audit procedure found live vulnerabilities in three additional markets and produced disclosures, one of which was acknowledged — a directly actionable security workflow.

**Industry relevance.** Polymarket publicly acknowledged ghost-filled orders and announced two urgent upgrades; the paper's evidence that the same class of flaw exists in all three other markets tested indicates the problem is architectural rather than an implementation slip at one venue. The size of the affected market — 96 prediction markets with $480.16M in total value locked and $2.709B in seven-day volume as of June 5, 2026 — makes the financial exposure material.

## Future Directions

- **Systematic evaluation of defenses and mitigations.** The paper's Section VI covers possible defenses and mitigations; quantifying the cost, latency, and capital-efficiency tradeoffs of each (for example, escrow or state-locking at match time versus the latency the off-chain book exists to avoid) is the natural next step.
- **Re-auditing after the upgrades.** Polymarket announced two urgent upgrades in response to the issue, and the v1 nonce mechanism was removed in v2. Whether the v2 design closes the atomicity gap, and whether the banned-account rules (automatic bans for nonce increments and for hook-code changes) are sufficient, remains an open question — the paper's own analysis of the hook vector is limited to the theoretical case because of those bans.
- **Extending the audit to more venues and other hybrid architectures.** Only three additional markets were tested, and all three were vulnerable. Broadening the audit would establish how general the flaw is, and whether the one design enabling direct attacker profit is representative.
- **Measuring the counterparty side of the loss.** The paper reports the responsible parties' avoided loss (over 61M USD) and develops conservative rules to separate attacker profit from market and user loss. Better attribution of the loss borne by counterparties and market makers in reverted bundles would complete the economic picture.

## Target Audience

Security researchers and auditors working on smart contracts and decentralized finance; protocol and exchange engineers who design order books, matching engines, or settlement layers; market makers and sophisticated traders active on prediction markets who need to understand the execution risk behind a displayed fill; and technically literate users or analysts of Polymarket who want a rigorous account of what "ghost-filled" orders actually are, how they are detected, and how large the measured impact is. Readers seeking a beginner-level introduction to prediction markets will find the background section accessible, but the analysis sections assume comfort with Ethereum execution traces and token standards.

## Authors’ abstract

Blockchain based prediction markets combine offchain order management with onchain settlement. This architecture supports user controlled custody, since users keep funds in wallets or smart contracts while submitting signed orders to an offchain order book. However, it creates an atomicity gap. An order may be valid when accepted or matched offchain, but become invalid before the corresponding onchain settlement transaction is executed. This behavior, often called ghost…

[The full abstract on arXiv](https://arxiv.org/abs/2609.17902)

[Read the original paper](https://arxiv.org/abs/2609.17902)

---

Canonical: https://crypto.world/paper/ghost-filled-orders-detecting-and-testing-atomicity-violations-in-non-2609.17902
