In this track: Smart contract security foundations
advanced · 4 MIN READ

Unsafe external call assumptions

Targets can fail, reenter or return unexpected data.

LET’S PICTURE IT

A public service counter can behave differently from the clerk you tested yesterday.

SEE IT FOR YOURSELF
A valid counter call, step by stepStep 1 / 4
A valid counter call, step by stepFunction requestincrement()No argumentsBefore executionstored count0A local teaching example with a defined starting stateIncoming callCheck function dispatchCheck coded conditionsRules passConditions passContinue executionA failed check can revert insteadCalculation0 + 1Result: 1Storage writecount = 1Persists if call succeedsCalculating a local value and storing it are separate stepsPersistent statecount1Later readGetter reports 1No new incrementState, logs and browser display have different roles

This example begins with count zero and a request to call increment(). No real contract is deployed.

Animated local teaching model. No wallet, RPC or live blockchain data. Some labels and hashes are abbreviated for readability.

List the trust boundary

An external address is another execution boundary. A familiar ABI or matching selector does not establish a cooperative implementation.

Handle several outcome shapes

The call can revert, return false under a schema, return malformed bytes or provide unexpectedly large output. Success handling and failure handling both need bounds.

Protect state during the handoff

The target may call back into reachable functions. Keep relevant invariants coherent and do not rely solely on the frontend’s intended order.

Test hostile dependencies

Local mocks should exercise the behaviors the protocol claims to tolerate. Document unsupported behaviors rather than silently assuming every token or oracle fits.

Reason about the scenario

dependency behavior matrix:
revert; false; malformed output; huge output; callback

For each, define expected application state and outcome.

Pseudocode or a simplified scenario for local reasoning. This is not a production contract or a completed security review.

QUICK CHECK · NO PRESSURE

Does a matching ABI establish a trustworthy target?

Your progress stays in this browser.
Keep exploring the original referenceSolidity documentation ↗

Original explanations by EtherTools. Examples are educational and source-linked; this site is independent of the Ethereum Foundation. Our approach.