In this track: Advanced security reasoning
advanced · 4 MIN READ

Calldata validation and type confusion

Decodable bytes can still represent the wrong intended action.

LET’S PICTURE IT

A correctly filled form can be submitted to the wrong department.

SEE IT FOR YOURSELF
Build a transfer call from typed fieldsStep 1 / 4
Build a transfer call from typed fieldstransfer(address,uint256)Recipient: 0x0000…0001Raw amount: 100Diagram labels abbreviate addresses; the lab shows full bytes4-byte selectora9059cbbEach box is one byte; this prefix is not a 32-byte wordWord 0 · recipient address12 zero bytes20 address bytes000…0001Left padding preserves the lower-order address valueSelector4 bytesa9059cbbAddress32 bytesword 0Amount32 bytesword 1 → 0x644 + 32 + 32 = 68 bytesThe integer does not contain token decimals or market price

The standard transfer interface takes an address and a raw integer amount. This diagram uses address one and amount one hundred.

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

Check framing and schema

Confirm the target interface, selector and parameter types. Similar word lengths do not establish that two declarations have the same meaning.

Validate semantic constraints

A successfully decoded address or integer may still violate protocol rules. Check allowed targets, amount ranges and relationships among fields.

Avoid blind reinterpretation

Reading raw bytes under a convenient alternate ABI can yield plausible but incorrect values. Preserve the exact expected schema and reject unsupported shapes.

Test confusing inputs

Include mismatched selectors, truncated tails and valid encodings with unauthorized values. Structural decoder checks and application authorization checks must both hold.

Work through the boundary

bytes fit address,uint256
→ values decoded
→ still check target, recipient, amount and authority

A simplified local review scenario. The example establishes a question to test, not a guarantee of production safety.

QUICK CHECK · NO PRESSURE

Does successful ABI decoding prove an action is authorized?

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.