Skip to content

ERC-20 Approval Race Condition

SAFE-0050 Token Standards Checked automatically by the scanner
1

What goes wrong

Changing an existing non-zero allowance with approve() lets a spender front-run the change and spend both the old and new allowance.

2

How to fix it

the pattern that is safe
token.safeIncreaseAllowance(spender, delta);
// or: approve(spender,0); approve(spender,newValue);
Known ERC-20 approve race. Use increase/decreaseAllowance.
Check your own contract for this

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