Skip to content

permit() Front-Running Griefing (DoS on Deposit)

SAFE-0207 Denial of Service Checked automatically by the scanner
1

What goes wrong

A deposit function calls permit() then transferFrom(). An attacker front-runs with the same permit (public in the mempool), consuming the nonce, so the victim's own deposit reverts on the now-invalid permit — a griefing DoS.

2

The vulnerable pattern

proof of concept — how it is exploited
// victim tx: permit(sig); transferFrom(...)
// attacker copies sig, submits permit(sig) first -> nonce consumed
// victim's permit(sig) reverts 'invalid signature' -> deposit fails.
3

How to fix it

the pattern that is safe
// wrap permit in try/catch so a consumed permit doesn't brick the deposit
try token.permit(...) {} catch {}
token.transferFrom(msg.sender, address(this), amount);
Wrap permit in try/catch to avoid front-run griefing.
Check your own contract for this

The SaferICO scanner runs 201 detectors over your Solidity source, SAFE-0207 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