$1,000,000 in security audit grants are live now, Apply here →

← Resource Hub

Perp DEX Security: The Attack Surface of Perpetual Exchanges

By the Guardian team Updated 6 min read

Perp DEX Security: The Attack Surface of Perpetual Exchanges

Quick answer. The biggest perp DEX risks are bad prices, flawed margin, funding and PnL math, liquidations that fail or can be gamed, and the keepers and admin keys that run the exchange. Each has caused exploits or Critical findings.

Watch: Perp DEX Security: The Attack Surface of Perpetual Exchanges 1:48
Video transcript

The biggest perp DEX risks are bad prices, flawed margin and funding math, broken liquidations, and the keepers and admin keys that run the exchange.

A wrong price pays the attacker. KiloEx lost about 7.5 million dollars in April 2025 after a forwarder behind its price feed accepted forged signatures.

Guardian's perps reports show four more routes: missing fields, wrong decimals, stale feeds, and orders filling at old trigger prices.

Accounting is where small errors become insolvency. GMX V1 lost about 42 million dollars when an attacker opened shorts without updating the average short price.

Liquidations keep the exchange solvent. Guardian has found them blocked by callback gas, fired on profitable positions, and gamed through one wei self-liquidations.

A keeper defect can halt the exchange while the contracts behave as written. A contract audit will not see it, so keepers and backends need their own review.

Whoever holds the admin keys holds the exchange. Attackers took admin control of Drift, whose Security Council was a two of five multisig with zero timelock, and withdrew about 285 million dollars.

Guardian has reviewed every GMX smart contract update since October 2022. Seven V2 reviews produced 351 findings, with 80 High or Critical. Synthetix BFP surfaced nine Criticals, Orderly three.

Read the full guide for the audit scope checklist, or get your perp DEX reviewed at guardian.security.

A perp DEX holds trader collateral and liquidity provider capital, and pays out on prices it reads from outside. Every trade, funding payment and liquidation is math on those prices.

So the attack surface is wider than a spot exchange’s. Attackers go after the price, the accounting, the liquidation path and the systems that execute orders.

This guide covers each one, with public incidents and findings from Guardian’s perps reports for GMX, Synthetix, Orderly, Veranta (formerly Avantis) and others.

How Perp DEX Designs Differ

The design decides who takes the other side of a trade, and where the risk concentrates.

DesignExamplesOther side of the tradeWhere risk concentrates
Oracle-priced poolGMX, VerantaLiquidity providersPrice feeds, pool accounting, keepers
Offchain matching, onchain settlementOrderly, Ethereal, SynthetixOther tradersSettlement math, matching engine, relayers
Order book on its own chainHyperliquidOther traders, with a backstop vaultThin markets, liquidation backstop, validators

The rows overlap. GMX prices trades from oracles, yet every request waits for a keeper to execute it, as our GMX V2 explainer shows.

Oracles and Execution Prices

A perp settles profit and loss on its price feed. A wrong price is a direct transfer from liquidity providers or other traders to the attacker.

In April 2025, KiloEx lost about $7.5 million. Rekt reports that its price feed sat behind a chain of contracts ending in a forwarder that accepted forged signatures.

The attacker set the ETH price to $100, opened leveraged longs, then set it to $10,000 and cashed out.

Thin markets are the other route. On March 26, 2025, a trader’s JELLY short was liquidated into Hyperliquid’s HLP vault.

CoinDesk reports the trader then bought JELLY on DEXs, where liquidity is minimal. The vault’s unrealized loss hit $13.5 million before validators delisted the market.

Guardian’s perps reports show four more ways in:

  • Missing fields: an omitted Lazer exponent could inflate prices 100 million times (Veranta, Critical).
  • Decimals: an Edge oracle integration computed prices at the wrong scale (GMX, Critical).
  • Staleness: markets would keep trading on the last index if the offchain signer stopped (Perp City, High).
  • Timing: limit orders could fill at a trigger price from minutes earlier (GMX, High).

For onchain price manipulation, see our guide to oracle manipulation attacks.

Margin, Funding and PnL Math

Accounting is where small errors become insolvency. A rounding slip, or a fee charged on the wrong amount, repeats across every position.

GMX V1, the older GLP exchange, lost about $42 million on July 9, 2025, through a reentrancy in a keeper-executed order callback, per Rekt.

The attacker opened shorts without updating the average short price. Citing GMX’s analysis, Rekt says BTC’s average short price fell from $109,505.77 to $1,913.70, and GLP rose from $1.45 to over $27.

Guardian’s reports hold the same class of bug:

  • Unpaid debt: traders with no open position could withdraw collateral while still owing debt (Synthetix BFP, Critical).
  • Funding: the market’s reported debt used the wrong funding entry (Synthetix BFP, Critical).
  • Partial closes: closing a tiny slice could erase accrued fees on the whole position (Veranta, Critical).
  • Fees: fees credited to the collector were not deducted from traders, leaving the books insolvent (Ethereal, Critical).
  • Rounding: per-size math on 6-decimal tokens could leave a market insolvent (GMX, High).

Liquidations, ADL and Insurance Funds

Liquidations keep the exchange solvent. When one fails, or fires on a healthy position, someone else pays the difference.

  • Blocked: users could push callback gas past Avalanche’s block gas limit, so liquidations would revert (GMX, Critical).
  • Wrongful: positions in large profit were treated as losses and could be liquidated (PariFi, Critical).
  • Gamed: a 1 wei deposit could be self-liquidated for a reward above its cost (Synthetix BFP, Critical).

When collateral runs out

Some losses exceed the collateral behind them. Exchanges cover the gap with an insurance fund, a backstop vault or auto-deleveraging (ADL).

Hyperliquid’s docs say ADL applies once an account or isolated position’s value turns negative. It closes profitable positions on the other side, ranked by unrealized PnL and leverage.

Whoever runs ADL also holds power. GMX’s README warns that keepers could extract value through transaction ordering and ADL execution.

Insurance paths break too. In Orderly’s settlement code, an insurance transfer was credited to both the fund and the trader (Critical).

At Perp City, the insurance fund could be charged for positions that were still solvent (High). Bad debt was shared using a stale margin total (High).

Our 13 liquidation vulnerabilities cover the rest.

Keepers, Admins and Offchain Risk

Keepers and trading backends

Pool-based perps such as GMX run in two steps: a user submits a request, and a keeper executes it later with signed prices.

A keeper defect can halt the exchange or execute the wrong trade while the contracts behave exactly as written. A contract audit will not see it.

Guardian’s review of GMX’s keeper service returned 55 findings, eight of them High. Its review of the Avantis V2 backend returned 68, with two Critical and six High.

In a Synthetix withdrawal flow review, one private key ran the relayer, watcher and teller roles (High).

Admin keys and upgrades

Admin powers can list markets, set oracles and change risk limits. Whoever holds them holds the exchange.

On April 1, 2026, attackers took admin control of Drift. Its Security Council was a 2-of-5 multisig with zero timelock, per Chainalysis.

They listed a token they created as collateral, priced it with an oracle they controlled, and withdrew about $285 million. Our Drift exploit breakdown covers how.

Audits find smaller admin gaps. Orderly’s setTokenDecimal had no access control, so anyone could inflate cross-chain balances (Critical).

Operations count too. A GMX delisting runbook would have flipped a global setting, changing borrowing fees on every market (High).

What a Perp Audit Should Cover

Use this as a scope check before you book a review:

  • Every price path: decimals, exponents, staleness, confidence and fallbacks.
  • Execution timing: prices must postdate the order or its trigger.
  • Listing rules and open interest caps sized to real market depth.
  • Invariants: each fee charged once, funding paid equals funding received, PnL backed by the pool.
  • Debt and collateral on every path: partial close, split, merge and withdrawal.
  • Liquidations at insolvency, at maximum callback gas and with hostile tokens.
  • Self-liquidation and liquidation rewards against the cost of opening a position.
  • ADL selection and sizing, insurance fund flows and bad-debt sharing.
  • Keeper and backend code, read against the contract math it mirrors.
  • Admin powers: thresholds, timelocks, and who can list markets or set oracles.
  • Runbooks and config scripts for listings, delistings and upgrades.

How Guardian Reviews Perp DEXs

Guardian has reviewed every smart contract update GMX has shipped since October 2022. Across seven pre-launch reviews of GMX V2, 351 findings were remediated or acknowledged, 80 of them High or Critical.

The Synthetix BFP Market review found 9 Criticals, with 22 invariants fuzzed across over 140 million runs. Orderly’s two-week review found 3 Criticals.

Every engagement runs two independent teams, backed by Helix, Guardian’s AI auditor. Guardian reviews keepers and backends in its offchain automation pentest.

Read the GMX case study, or compare firms in Best Perp DEX Auditors.

Frequently Asked Questions

What is auto-deleveraging in a perp DEX?

Auto-deleveraging (ADL) covers losses that exceed a position’s collateral by closing profitable positions on the other side. Hyperliquid ranks them by unrealized PnL and leverage. An audit should check how positions are selected, sized and priced.

Does a smart contract audit cover a perp DEX’s keepers?

No. A contract audit reviews the onchain code. Keepers, matching engines, relayers and price services need their own review, which Guardian ran for GMX’s keeper service and the Avantis V2 backend.

What happened in the Hyperliquid JELLY incident?

On March 26, 2025, a trader’s JELLY short was liquidated into Hyperliquid’s HLP vault, and they then bought JELLY on thin DEX markets. CoinDesk reports the vault’s unrealized loss hit $13.5 million before validators delisted the market.

Sources

Get your perp DEX reviewed by Guardian

Guardian reviews the contracts, keepers and trading backends of perpetual exchanges, from oracle paths to liquidations.