Skip to content
low Access Control No SWC entry CWE-284

extcodehash / Code Check Bypass Assumptions

SAFE-0239 Access Control Checked automatically by the scanner
1

What goes wrong

Logic assumes an address is 'safe' because its extcodehash matches a known value or is non-zero. Code can differ at call time (proxies, metamorphic contracts) or an EOA can become a contract later, breaking the assumption.

2

The vulnerable pattern

proof of concept — how it is exploited
// require(a.codehash == KNOWN); // a is a proxy
// the proxy's implementation is upgraded post-check -> behaviour changes
// while codehash (of the proxy) stays the same.
3

How to fix it

the pattern that is safe
// don't equate 'known codehash' with 'trusted forever'; re-validate intent,
// or restrict to an explicit allowlist you control.
Codehash equality is not a durable trust signal.
Check your own contract for this

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