Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
Free 30-min Web3 Consultation
Book Consultation
Smart Contract Security Audits
View Audit Services
Custom DeFi Protocol Development
Explore DeFi
Full-Stack Web3 dApp Development
View App Services
LABS
Guides

Setting Up a MEV Incident Response Protocol

A technical guide for developers and protocol teams on establishing a formal incident response plan for MEV-related events, including team formation, escalation procedures, and on-chain coordination.
Chainscore © 2026
introduction
INTRODUCTION

Setting Up a MEV Incident Response Protocol

A structured approach to detecting, analyzing, and mitigating malicious Maximal Extractable Value (MEV) activity on your protocol.

Maximal Extractable Value (MEV) represents profits validators or searchers can extract by reordering, inserting, or censoring transactions within a block. While some MEV is a natural market function (e.g., arbitrage), malicious forms like time-bandit attacks, sandwich attacks, and long-range reorganizations pose significant security and user experience risks. An incident response protocol is a pre-defined plan your team executes when such an attack is detected, aiming to minimize damage, preserve evidence, and restore normal operations.

The core of your response plan is a monitoring and detection layer. This involves setting up real-time alerts for on-chain anomalies. Key metrics to track include sudden spikes in gas prices for specific transaction patterns, abnormal failure rates for user transactions, and the appearance of known malicious searcher addresses or contract patterns. Tools like Flashbots Protect RPC, Blocknative, or custom EigenPhi analytics dashboards can feed data into alerting systems such as PagerDuty or Slack webhooks. The goal is to achieve low-latency detection, as the window for effective intervention during a live attack is often measured in blocks.

Upon detecting a potential incident, the first step is triage and classification. Your team must quickly determine the attack vector and its impact. Is it a sandwich attack targeting your DEX's liquidity pool? A generalized frontrunning bot exploiting a pending governance vote? Use block explorers like Etherscan and MEV-specific tools like Tenderly's simulation features or Phalcon's transaction tracer to reconstruct the attack. Document everything: attacker addresses, victim transactions, profit extracted, and the exact contract functions involved. This data is crucial for both immediate mitigation and post-mortem analysis.

With the attack understood, you can enact mitigation strategies. Technical responses can include: temporarily increasing transaction slippage tolerances on your frontend, pausing vulnerable contract functions via a guardian multisig, or submitting counter-measure bundles through private transaction relays like Flashbots to neutralize the attack. For example, if a searcher is frontrunning large DEX swaps, you could use the Flashbots RPC to send a backrunning transaction that claims the arbitrage profit for your protocol's treasury instead. The specific action depends entirely on the attack type and your protocol's architecture.

After containing the incident, conduct a formal post-mortem analysis. This report should detail the timeline, root cause, financial impact, and effectiveness of the response. Crucially, it must outline corrective actions to prevent recurrence. These might involve smart contract upgrades (e.g., implementing commit-reveal schemes or threshold encryption for sensitive transactions), adjusting protocol parameters, or improving monitoring rules. Share key, non-sensitive learnings with the ecosystem. Finally, test your response plan regularly through tabletop exercises simulating different MEV attack scenarios to ensure team readiness.

prerequisites
SETUP GUIDE

Prerequisites

Essential tools and accounts required to establish a protocol for detecting and responding to MEV attacks.

Before implementing an MEV incident response protocol, you need a foundational development environment and access to key data sources. This requires a Node.js environment (v18 or later) for running scripts, Python 3.10+ for data analysis, and a package manager like npm or yarn. You will also need a code editor such as VS Code and familiarity with the command line. The core of the setup involves configuring access to blockchain data via RPC providers like Alchemy or Infura, and MEV-specific data streams from services like Flashbots.

Securing API keys and setting up a secure vault is critical. You will need to create accounts and obtain API keys for: an Ethereum RPC endpoint (e.g., from Alchemy), the Flashbots Protect RPC for accessing the private mempool, and potentially Blocknative for mempool streaming. Store these keys securely using environment variables or a secrets manager—never hardcode them. For on-chain automation, you will need a funded Ethereum wallet (a dedicated operational account) with its private key secured, and the wallet address added to any allowlists for services like Flashbots.

The final prerequisite is installing the necessary libraries and understanding the basic workflow. Key npm packages include ethers.js v6 for blockchain interaction, viem for type-safe Ethereum tooling, and flashbots-sdk for bundling transactions. In Python, libraries like web3.py, pandas for data analysis, and requests for API calls are essential. With these in place, you can construct the basic flow: monitor pending transactions via a secured RPC, analyze them for known MEV attack patterns (like sandwich trades), and prepare automated response transactions to be submitted through a private channel like Flashbots.

key-concepts-text
OPERATIONAL GUIDE

Key Concepts for MEV Incident Response

A structured protocol for detecting, analyzing, and mitigating Maximal Extractable Value (MEV) incidents is essential for protocol security and user protection.

A MEV Incident Response Protocol is a formalized set of procedures for identifying and responding to malicious or anomalous extraction of value from a blockchain network. This is distinct from general security incidents, as it focuses on the unique economic attacks enabled by block production ordering, such as sandwich attacks, time-bandit attacks, or long-range reorganizations. The primary goals are to minimize user losses, preserve protocol integrity, and gather forensic data to prevent future occurrences. Establishing this protocol requires coordination between core developers, validators, searchers, and data analysts.

The first phase is Detection and Triage. This involves setting up real-time monitoring for MEV-specific signals. Key indicators include: - Unusual spikes in gas prices or failed transaction rates on a DEX. - Identical transaction hashes appearing in multiple blocks (indicating a reorg). - The presence of known malicious searcher addresses in a high percentage of blocks. Tools like the Flashbots MEV-Share Dashboard, EigenPhi, and custom Etherscan alert bots can automate this monitoring. When an alert triggers, the response team must quickly assess the incident's scope, affected users, and the exploit vector to determine severity.

Following triage, the Containment and Analysis phase begins. For live attacks, possible technical responses include: - Validator Coordination: Communicating with trusted validators or relay operators to temporarily exclude transactions from a malicious bundler. - Parameter Adjustment: Temporarily changing protocol parameters (e.g., increasing minimum bid for block space) to disrupt the attack's economics. Concurrently, forensic analysis is critical. Teams should use block explorers, MEV inspection tools like EigenPhi or Mev.io, and transaction simulation to reconstruct the attack. The goal is to create a detailed timeline and quantify extracted value.

The final phase is Eradication, Recovery, and Post-Mortem. Eradication involves implementing a permanent fix, which could be a smart contract patch, a change to validator client software, or an update to a relayer's inclusion list. Recovery focuses on user compensation, which is complex and often involves governance decisions and treasury funds. A formal Post-Mortem report should be published, detailing the incident timeline, root cause, response effectiveness, and specific preventative measures adopted. This transparency builds trust and contributes to the broader ecosystem's security, turning an incident into a learning opportunity for all protocols.

response-team-roles
MEV INCIDENT RESPONSE

Core Response Team Roles and Responsibilities

A successful MEV incident response requires a clearly defined team structure. These roles coordinate to detect, analyze, and mitigate threats to protocol users and network stability.

01

Incident Commander

The Incident Commander is the central decision-maker and coordinator during a crisis. They are responsible for:

  • Declaring the official start and end of an incident.
  • Assigning tasks to all other team members.
  • Making final decisions on mitigation strategies (e.g., pausing contracts, coordinating with validators).
  • Serving as the single point of contact for external communications with other protocols or foundations. This role requires deep protocol knowledge and the authority to execute time-sensitive actions.
02

Technical Lead / Searcher

This role is filled by an expert in Ethereum transaction mechanics and MEV strategies. Their responsibilities include:

  • Real-time analysis of the mempool and block data to identify the malicious MEV bundle or sandwich attack.
  • Reverse-engineering the attacker's strategy to understand the exploit vector.
  • Proposing and simulating potential counter-measures, such as crafting a counter-bundle to neutralize the attack or front-run the malicious actor.
  • They work closely with the Relay Coordinator to understand what can be feasibly submitted.
03

Relay Coordinator

The Relay Coordinator manages the critical link to block builders. This role requires established relationships with major relay operators. Their duties are:

  • Communicating directly with relays (e.g., BloXroute, Flashbots Protect, Titan) to explain the incident and request cooperation.
  • Submitting the team's approved counter-bundles or censorship requests to the relay network.
  • Monitoring which relays are complying with requests and escalating if necessary.
  • Understanding each relay's specific policies and API for urgent submissions.
04

Protocol Liaison

This role is the bridge between the MEV response team and the protocol team under attack. Key responsibilities include:

  • Immediately notifying the protocol's core developers and security team.
  • Gathering internal data (smart contract logs, admin key status) that is not public.
  • Coordinating on-chain actions, such as executing a pause() function if the team controls a multisig.
  • Providing the protocol team with a technical post-mortem to aid in fixing the root cause.
05

Communications Lead

The Communications Lead manages all internal and external messaging to prevent panic and misinformation. Their tasks include:

  • Updating the internal team chat (e.g., War Room) with clear, concise status reports.
  • Drafting public statements for social media (Twitter, Discord) to inform users about the incident and ongoing mitigation, without revealing tactical details.
  • Preparing post-incident transparency reports for the community.
  • Filtering external noise and keeping the core team focused on the technical response.
06

Legal & Compliance Officer

This role assesses the regulatory and legal implications of the team's actions. They are responsible for:

  • Evaluating the legal risks of proposed counter-measures (e.g., is submitting a counter-bundle considered market manipulation?).
  • Advising on data privacy when handling user transaction data during analysis.
  • Ensuring the team's actions comply with the terms of service of relays and infrastructure providers.
  • Documenting all decisions and actions for potential regulatory review or legal defense.
detection-triggers
FOUNDATION

Step 1: Define Detection Metrics and Triggers

The first step in establishing a MEV incident response protocol is to define what constitutes an incident. This involves identifying the specific on-chain metrics and off-chain signals that will trigger your team's response process.

A detection metric is a quantifiable data point that signals potential MEV-related activity. Common on-chain metrics include gas price spikes (e.g., a sudden 100+ gwei increase on Ethereum mainnet), unusual transaction volume to a specific contract, or abnormal slippage percentages on DEX trades that deviate from the prevailing market rate. For example, a 5% slippage on a stablecoin swap when the pool is well-funded is a strong indicator of a sandwich attack in progress. These metrics should be tied to concrete thresholds that, when breached, initiate an alert.

Triggers are the logical rules that combine metrics into actionable alerts. A trigger could be: IF gas_price > 150 gwei AND transaction_origin == known_attacker_address THEN severity = CRITICAL. You should define triggers for different MEV attack vectors: sandwich attacks, liquidations, arbitrage opportunities, and time-bandit attacks. Using services like the Flashbots MEV-Share dashboard or building custom queries with Dune Analytics or Flipside Crypto can help you monitor these patterns in real-time.

It's crucial to calibrate these triggers to minimize false positives. Setting a gas threshold too low might alert you to normal network congestion, while setting it too high could mean missing a critical attack. Start with conservative values based on historical data—like the 90th percentile of gas prices for your typical operations—and adjust based on observed incidents. Document each trigger with its purpose, data source, threshold value, and expected response owner (e.g., DevOps, Trading, Security). This documentation forms the core of your response playbook.

escalation-procedures
SETTING UP A MEV INCIDENT RESPONSE PROTOCOL

Step 2: Establish Escalation and Communication Procedures

A clear, documented process for escalating and communicating during a MEV-related security incident is critical for minimizing damage and coordinating an effective response.

The first step is to define your incident severity tiers. A common framework uses four levels: Severity 0 (Critical), a live exploit causing direct, ongoing fund loss; Severity 1 (High), a confirmed vulnerability that could lead to critical loss; Severity 2 (Medium), a suspicious transaction pattern or potential vulnerability; and Severity 3 (Low), a general inquiry or false positive. Each tier must have explicit, pre-defined triggers. For example, a Severity 0 trigger could be a sandwich attack draining a protocol's primary liquidity pool, while a Severity 1 trigger might be the discovery of a flawed auction logic in your searcher codebase.

With tiers established, map out the escalation matrix. This is a simple table or on-call tool configuration that dictates who is notified and when. For a Severity 0 event, the protocol's core engineering lead, security lead, and a designated communications lead should be paged immediately, 24/7. Severity 1 might page the on-call engineer and security lead within 30 minutes. Document primary and secondary contacts, their roles, and exact contact methods (e.g., PagerDuty, Telegram War Room, phone). Ensure this list is kept current and accessible offline.

Parallel to technical escalation, prepare communication templates. Draft pre-written messages for internal teams, public announcements, and key ecosystem partners like block builders, relay operators, or data providers (e.g., EigenPhi, Flashbots). Templates should include placeholders for incident ID, affected contracts, current status, and next update time. For public channels like Twitter or Discord, maintain a calm, factual tone: "We are investigating unusual transaction activity related to [Protocol Name]. User funds in [Specific Contract] are potentially at risk. We will provide an update within 60 minutes." This prevents panic and misinformation.

Establish your primary communication channels and war rooms. Designate a private, internal channel (e.g., a Slack or Telegram group) for the core response team to coordinate technical mitigation. For broader ecosystem coordination, you may need a separate channel with trusted white-hat researchers, auditors, and partner protocols. Crucially, decide in advance on a single, authoritative public channel (like an official Twitter account or a pinned Discord post) for all external updates to ensure message consistency and avoid confusion during a crisis.

Finally, integrate this plan with your technical tooling. Your monitoring alerts from Step 1 should automatically tag incidents with a severity level and trigger the first step of your escalation matrix via your on-call system. Run regular, tabletop exercises simulating different MEV attack vectors—like a time-bandit attack on a PoS chain or a DDOS attack against your transaction bundler. These drills test your procedures, update contact lists, and refine communication templates, ensuring your team can execute the plan under real pressure.

RESPONSE TIERS

MEV Incident Severity and Response Matrix

Classification of MEV incidents by severity level and corresponding response actions for validators and searchers.

Severity LevelImpact DescriptionExample IncidentValidator ResponseSearcher Response

Critical (P0)

Network liveness threatened, >$10M user funds at risk

Time-bandit attack causing chain reorg > 5 blocks

Immediate pause of block proposals, alert relay operators

Halt all private transaction submission, notify partners

High (P1)

Significant user loss ($1M-$10M), protocol exploit enabled

Sandwich attack draining a major DEX pool

Review and filter pending transactions, increase block delay

Blacklist malicious searcher addresses, audit bundle logic

Medium (P2)

Moderate user loss (<$1M), degraded network performance

Failed arbitrage bundle causing gas price spike to >500 gwei

Monitor for repeat patterns, adjust gas priority settings

Review failed bundle simulation, implement stricter pre-checks

Low (P3)

Minor inefficiency, no direct fund loss

Non-optimal ordering causing minor slippage for users

Log incident for pattern analysis, no immediate action

Internal review of bidding strategy, adjust profit thresholds

technical-mitigation-steps
MEV RESPONSE PROTOCOL

Step 3: Technical Mitigation and On-Chain Actions

Once a malicious MEV opportunity is identified, a structured on-chain response is critical to protect users and protocol assets. This guide outlines the technical steps for executing a mitigation.

The core action in an MEV incident response is often the execution of a counter-transaction. This is a transaction, submitted by the protocol's authorized responder, designed to neutralize the economic advantage of the attacker's pending bundle. For example, if an attacker has a bundle that profits from arbitraging a mispriced liquidity pool, the counter-transaction would execute the same profitable trade first, moving the price and eliminating the arbitrage opportunity. This action is commonly referred to as 'JIT (Just-In-Time) liquidation' or 'backrunning the attacker'.

Executing this requires a dedicated response bot with three key capabilities: high-frequency blockchain data access, rapid transaction construction, and privileged access to transaction submission. The bot must monitor the mempool for specific threat signatures (like known attacker addresses or profit-calculation function calls) using services like Flashbots Protect RPC or BloXroute. Upon detection, it uses a pre-authorized smart contract, often called a 'firewall' or 'circuit breaker', to atomically execute the mitigation logic.

Here is a simplified conceptual example of a counter-transaction contract function for neutralizing a simple arbitrage attack on a Uniswap V3 pool:

solidity
function neutralizeArbitrage(address pool, uint256 amountIn) external onlyResponder {
    // 1. Check current price and calculate profitable output
    (uint160 sqrtPriceX96, , , , , , ) = IUniswapV3Pool(pool).slot0();
    // 2. Execute the trade that the attacker intended to profit from
    IERC20(tokenIn).transferFrom(treasury, address(this), amountIn);
    IUniswapV3Pool(pool).swap(...);
    // 3. Send captured funds back to protocol treasury
    IERC20(tokenOut).transfer(treasury, IERC20(tokenOut).balanceOf(address(this)));
}

Transaction priority is won through Max Priority Fee (tip) bidding. The responder must outbid the attacker's gas price to ensure their counter-transaction is included in the block first. This often requires setting a dynamic gas strategy that monitors the mempool and submits transactions with a tip significantly above the current network base fee. Using private transaction relays like Flashbots or Titan is essential to prevent the counter-strategy itself from being frontrun and to avoid congesting the public mempool.

Post-execution, all actions and fund flows must be logged and analyzed. This includes recording the block number, transaction hashes of both the malicious bundle and the counter-action, gas costs incurred, and any assets secured or lost. This data is crucial for post-mortem analysis, refining detection heuristics, justifying the use of protocol funds for gas, and providing transparency to governance. The process should be documented in a standard template for consistency.

Finally, establish clear governance and authorization boundaries. The private keys or multi-sig signers controlling the responder bot and treasury funds should be distinct from development keys. Define explicit spending limits for gas in emergency scenarios and create a ratification process where the protocol's DAO or security council reviews and approves all mitigation actions after the fact, ensuring accountability for this powerful capability.

tools-monitoring
MEV RESPONSE

Essential Monitoring Tools and Dashboards

Proactive monitoring is critical for detecting and responding to MEV-related incidents. This guide outlines the key tools and dashboards for building an effective response protocol.

06

Incident Response Runbook Template

Document a clear, step-by-step process for when an MEV incident is detected. A runbook ensures a coordinated response. Structure it with:

  1. Triage: Confirm the incident using dashboards (e.g., is it a sandwich attack on our users?).
  2. Containment: Immediate actions (e.g., pausing vulnerable contracts, adjusting router parameters).
  3. Investigation: Gather data (transaction hashes, attacker addresses, profit calculations).
  4. Communication: Notify stakeholders via pre-defined channels.
  5. Post-Mortem: Document root cause and update monitoring rules. Store this as a living document in a team-accessible wiki.
post-mortem-process
INCIDENT RESPONSE

Step 4: Post-Incident Analysis and Protocol Updates

After an MEV attack is contained, a structured post-mortem process is critical for hardening your protocol against future threats. This step transforms reactive defense into proactive security.

The immediate goal of post-incident analysis is to create a detailed incident report. This document should catalog the attack vector (e.g., sandwich attack, time-bandit manipulation), the financial impact in USD and native tokens, the specific transaction hashes involved, and the timeline from detection to resolution. This report serves as the single source of truth for internal teams, auditors, and, if necessary, public communication. Tools like Tenderly or Etherscan's transaction decoder are invaluable for reconstructing the attack flow.

With the report in hand, conduct a root cause analysis (RCA). Move beyond the symptom—lost user funds—to identify the underlying protocol weakness. Was it a vulnerable slippage tolerance setting in a DEX router integration? An overly permissive validator selection mechanism? A flaw in the economic design of a bonding curve? The RCA should pinpoint the exact smart contract function, configuration parameter, or system design flaw that was exploited. This analysis often requires tracing calls through multiple contracts using a debugger.

The RCA directly informs the protocol update plan. This is a prioritized list of code changes, parameter adjustments, and process improvements. For example: 1. Update swapRouter contract to enforce a maximum slippage of 0.5%. 2. Implement a circuit breaker that halts deposits if MEV bot activity spikes by 300% in a block. 3. Migrate from a first-price sealed-bid auction to a fair ordering service like SUAVE. Each item must have a clear owner and timeline. Smart contract upgrades should follow a rigorous governance and testing process on a testnet.

Finally, integrate the lessons learned into your protocol's ongoing operations. Update your monitoring dashboards with new alerts for the identified attack pattern. Revise your risk parameter framework and documentation. If the incident revealed a novel MEV vector, consider publishing a write-up (without exposing new vulnerabilities) to contribute to ecosystem security. This cycle of analyze, patch, and improve is what separates resilient DeFi protocols from those repeatedly exploited.

MEV Incident Response

Frequently Asked Questions

Common questions and solutions for developers implementing a protocol to detect and respond to Maximal Extractable Value (MEV) attacks.

The primary goal is to detect, analyze, and mitigate the impact of harmful MEV extraction in real-time. This involves monitoring the mempool and on-chain state for patterns like sandwich attacks, time-bandit attacks, or long-tail reorgs. The protocol aims to protect end-users from financial loss and maintain the integrity of the application's intended transaction ordering. It is not about preventing all MEV, but about creating a defensive system that can identify malicious extraction and trigger predefined countermeasures, such as transaction cancellation, alerting, or shifting to a more secure mempool like a private RPC.

How to Set Up a MEV Incident Response Protocol | ChainScore Guides