Skip to content

State Updated Before Transfer Success Confirmed

SAFE-0211 Logic / State Checked automatically by the scanner
1

What goes wrong

Internal accounting (balances, shares) is written before the external token transfer is confirmed to succeed. If the transfer silently fails or returns false, the ledger and the real token balance diverge.

2

The vulnerable pattern

proof of concept — how it is exploited
// balances[user] += amt; token.transferFrom(user, this, amt);
// transferFrom returns false (fee token / paused) but isn't checked
// -> user credited without paying.
3

How to fix it

the pattern that is safe
bool ok = token.transferFrom(msg.sender, address(this), amount);
require(ok, "transfer failed");
balances[msg.sender] += amount;   // only after confirmed
Confirm the transfer, then update state.
Check your own contract for this

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