Join our Newsletter — 33% off our NHI Course
Home› Glossary› Cyber Security› Sandwich Attack
Cyber Security

Sandwich Attack

← Back to Glossary
By NHI Mgmt Group Updated October 31, 2026 Domain: Cyber Security

A sandwich attack is a trading tactic where an attacker places transactions before and after a victim’s pending trade to profit from the price movement they create. On Ethereum, it relies on mempool visibility and fast execution. The victim receives a worse price, while the attacker captures the spread created by the manipulated order flow.

How a Sandwich Attack Works

A sandwich attack is built around ordering, not code. The attacker watches a pending trade in the mempool, buys ahead of it, lets the victim’s order move the price, then sells into that movement. The tactic depends on public transaction visibility, low-latency execution and a market structure where transaction ordering can be influenced.

On Ethereum and similar networks, this is often discussed as a form of maximal extractable value, because the attacker is extracting value from how the trade is sequenced rather than from the asset itself. The core mechanic is simple: the victim’s execution changes the price, and the attacker captures that induced spread.

Why Mempool Visibility Matters

The mempool is the attacker’s information advantage. If a pending trade is visible before inclusion, the attacker can estimate its likely price impact and position transactions around it. That makes sandwich attacks especially effective against larger swaps, thin liquidity pools, or routes where slippage tolerance leaves room for predatory ordering.

The danger comes from the combination of transparency and adversarial speed. In a public blockchain, visibility is a feature, but it also gives searchers and arbitrage bots a chance to compete on ordering. When blockspace is competitive, the attacker who can react fastest often gets the first and last transaction in the sequence.

For a practical overview of how smart contract ecosystems expose these kinds of execution risks, see Smart Contract Security Guide.

Where the User Harm Comes From

A sandwich attack does not usually break the protocol. Instead, it degrades the trade outcome for the victim. The user receives a worse execution price, may suffer more slippage than expected, and can lose value even when the underlying market does not move much on its own. That makes it a market integrity problem as much as a technical one.

The attacker’s profit is created by forcing the victim to trade through a manipulated price path. In effect, the victim pays the cost of the attack through execution quality, while the attacker monetises the temporary distortion. This is why the tactic is closely associated with decentralized exchanges and other environments where order sequencing is economically meaningful.

How Defenders Reduce Exposure

Defence is usually about reducing predictability, limiting slippage, and making transaction ordering harder to exploit. Users and platforms can narrow the window by avoiding overly loose slippage settings, splitting large trades, and using routing or execution mechanisms that reduce public exposure before settlement. In some cases, private transaction submission or protected order flow can also reduce the chance of being targeted.

For protocol and application teams, the deeper lesson is that fairness depends on more than contract correctness. If the surrounding market design leaves users exposed to visible pending orders and easy ordering games, the result can be systematic value leakage even when the smart contract behaves as intended. That is why transaction privacy, execution design and monitoring all matter together.

When teams are reviewing smart contract and trading-path risks, the same controls that help with front-running, price manipulation and MEV are usually relevant here as well.

Risk and Threat Considerations

Sandwich attacks are a material market-execution risk because they turn transaction visibility into extractable value. The harm is often subtle, the trade still succeeds, but the user receives worse execution and the attacker captures the difference.

Failure mechanism: The attacker observes a pending trade, inserts a buy transaction before it and a sell transaction after it, and profits from the price movement the victim’s own order creates.

Impact: Victims experience slippage, poorer pricing and value loss, while repeated exploitation can erode trust in the venue or routing path.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

MITRE ATT&CK addresses the attack and risk surface, while OWASP ASVS and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP ASVSV8 — AuthorizationSandwich attacks exploit transaction-order exposure around authorised trade execution.
Recommendation — Design execution paths to minimise adversarial ordering opportunities around user-authorised actions.
NIST CSF 2.0PR.AA-05 — Assets are managed commensurate with riskTrade flows and pending-order exposure need risk-based handling and visibility controls.
Recommendation — Manage trading-path exposure and execution controls according to their market-manipulation risk.
MITRE ATT&CKT1595 — Active ScanningThe attacker first observes exposed pending activity to identify profitable targets.
Recommendation — Monitor for repeated observation of exposed trade flow and suspicious pre-positioning behavior.

Practitioner Guidance

What to watch for: Treat persistent slippage complaints, repeated pre-trade price movement, and unusual ordering around large swaps as signals that execution quality may be being gamed. The issue is often easiest to see in aggregate, not from a single trade.

Governance implication: Teams that run trading interfaces, routers or on-chain execution paths should own the user-experience risk, not just the contract risk. If the environment exposes pending order flow, then sequencing protection and transaction handling are part of secure design, not optional polish.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on October 31, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org