Skip to content

Front-Runnable Reveal (No Commit-Reveal)

SAFE-0252 MEV / Ordering Checked automatically by the scanner
1

What goes wrong

A value that should be secret until execution (a bid, a move, a claim code) is submitted in the clear in a single transaction. Searchers read it in the mempool and front-run, capturing the advantage the secrecy was meant to protect.

2

The vulnerable pattern

proof of concept — how it is exploited
// bid(amount) is public in the mempool.
// searcher sees it and submits bid(amount+1) with higher gas -> wins.
3

How to fix it

the pattern that is safe
// commit hash first, reveal later
function commit(bytes32 h) external { commits[msg.sender] = h; }
function reveal(uint256 v, bytes32 salt) external { require(keccak256(abi.encode(v,salt))==commits[msg.sender]); }
Use commit-reveal for values that must stay secret.
Check your own contract for this

The SaferICO scanner runs 201 detectors over your Solidity source, SAFE-0252 among them. Paste an address or the source itself — a small per-scan fee, shown before you sign, or unlimited on any plan.

Run the scanner See how it is attacked Read the docs