mev-frontrunning
Skill36 starsChanged 5 months agoMITView on GitHub
Detect MEV exposure and front-running risks — sandwich attacks, missing commit-reveal, missing/manipulable deadlines, slippage absent, public mempool dependence. Activate on swaps, mints, liquidations, NFT mints with reveals, auctions, and any function whose ordering can extract value.
In this repository44 other files it gives its agents.
- access-controlSkill
- approval-issuesSkill
- caching-and-incrementalSkill
- centralization-riskSkill
- confidence-scoringSkill
- cosmwasmSkill
- cross-chain-messagingSkill
- cross-contract-stateSkill
- delegatecall-risksSkill
- diamond-eip2535Skill
- dos-vectorsSkill
- erc1271-contract-signaturesSkill
- erc4337-account-abstractionSkill
- erc4626-inflationSkill
- false-positive-feedback-loopSkill
- fee-on-transferSkill
- flash-loan-attacksSkill
- initializationSkill
- inline-assemblySkill
- integer-issuesSkill
- intents-erc7683Skill
- known-good-comparisonSkill
- liquidation-cascadeSkill
- mev-pbsSkill
- multi-pass-self-critiqueSkill
- oracle-manipulationSkill
- oracle-redundancySkill
- permit2-patternsSkill
- pragma-and-addressesSkill
- progress-and-streamingSkill
- reentrancySkill
- restaking-eigenlayerSkill
- selfdestruct-eip6780Skill
- signature-malleabilitySkill
- signature-replaySkill
- solana-anchorSkill
- storage-layoutSkill
- stylus-rustSkill
- token-compatibilitySkill
- tx-context-misuseSkill
- unchecked-callsSkill
- ve-lock-governanceSkill
- vyper-specificSkill
- zk-verifier-bugsSkill
The file
Files
MEV / front-running detection
When this applies
- Swaps, mints, redemptions on AMMs / vaults
- NFT mints with random/reveal mechanics
- Auctions, Dutch auctions, English auctions
- Liquidations
- Trade routers
- DEX aggregator paths
- Any function with
amountOutMinor slippage parameters
Detection patterns
Missing slippage parameter (HIGH)
function swap(address tokenIn, uint256 amountIn) external {
router.swapExactTokensForTokens(amountIn, 0, path, msg.sender, block.timestamp);
// ^ amountOutMin = 0 → 100% sandwichable
}Manipulable deadline (HIGH)
router.swap(..., block.timestamp); // ← deadline = now means no deadline at allSearcher can delay your tx indefinitely. Use a real deadline (block.timestamp + 15 min or user-supplied).
Permit + transferFrom front-running (MEDIUM)
Submitting permit() separately from the consuming tx lets an MEV bot front-run the permit and grief the user. Bundle in one tx.
Reveal-based randomness without commit-reveal (HIGH)
function mintRare() external {
uint256 r = uint256(keccak256(abi.encode(block.timestamp, msg.sender)));
if (r % 100 == 0) _mint(msg.sender, RARE_ID); // ← searcher can simulate and skip
}Searcher simulates → only sends tx if outcome is favorable. Use commit-reveal or Chainlink VRF.
block.prevrandao / block.difficulty for randomness (HIGH)
Proposer can manipulate post-merge prevrandao within bounded ranges; predictable enough for valuable mints.
NFT mint without per-tx limits + public sale (MEDIUM)
Bots will sweep entire allocation. Not a vuln per se but a UX/fairness issue worth flagging.
Just-in-time (JIT) liquidity exposure (LOW)
LPs in concentrated-liquidity pools can be JIT'd. Inform user, not a fix.
Auction first-price bidding (HIGH)
First-price sealed bids on a public mempool = bid front-run. Use commit-reveal.
Approve race (MEDIUM)
Classic ERC-20 approve(spender, X) → approve(spender, Y) front-run lets spender drain X + Y. See [[approval-issues]].
Severity rubric
| Pattern | Severity |
amountOutMin = 0 on user-facing swap | High |
Deadline = block.timestamp on user-facing swap | High |
| Block-data randomness for valuable outcomes | High |
| Commit-reveal missing on sealed bid | High |
| Permit + transferFrom unbundled | Medium |
| Bot-sweep risk on public NFT mint | Medium |
| JIT-LP exposure | Low |
| Display-only ordering issue | Info |
Remediation patterns
- Slippage: surface as a user parameter, enforce a sane minimum.
- Deadline: surface as user parameter, never
block.timestamp. - Randomness: Chainlink VRF, RANDAO with epoch lookback, or commit-reveal.
- Bid auctions: commit-reveal (hash bid + nonce → reveal after close).
- For high-value flows: support private mempools (Flashbots Protect, MEV-Share, Berachain's BBS).
- Bundle permit + use in single tx.
- ERC-20 approval: prefer
permit(EIP-2612) orincreaseAllowance.
False-positive notes
- Atomic protocol-internal swaps with no user-controlled output token aren't front-runnable.
- Sequenced L2s (Arbitrum One, Base) currently have no public mempool ordering attack — flag risk as L2-conditional.
- Deadline checks that come from a trusted off-chain oracle/router (e.g. CoW Protocol) can be skipped.
Related
- [[oracle-manipulation]] — sandwich attacks are oracle moves
- [[approval-issues]]
- [[signature-replay]] — replayable signed messages are MEV gold
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

