In this track: Execution traces and low-level calls
advanced · 4 MIN READ

Return-data griefing explained

Large attacker-controlled output can make caller-side processing expensive.

LET’S PICTURE IT

A small request can trigger an enormous attachment that overloads the receiving desk.

SEE IT FOR YOURSELF
Use temporary memory in one execution frameStep 1 / 4
Use temporary memory in one execution framePointer wordmemory address 0x40value: 0x80Working areabegins at 0x80not a storage slotCompiler memory conventions differ from persistent storage layoutValue 42hex: 0x2aleft-padded in a wordMSTOREoffset 0x80bytes 0x80–0x9fA retained manual allocation must also maintain the memory pointerMLOADoffset 0x80read 32 bytesStack result42same stored wordMLOAD and SLOAD access different data locationsRETURN rangeoffset 0x80size 32 bytesOutput bytesencoded integer 42caller interprets schemaEach message-call frame has its own memory working space

This frame uses temporary byte-addressed memory. Solidity normally keeps a free memory pointer at address 0x40, initially pointing to 0x80.

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

Identify who controls the bytes

An external target may return or revert with a large payload. The caller cannot assume a familiar short ABI result merely because it requested a simple function.

Account for memory and copying

Copying the complete buffer into memory can expand memory and consume gas. Automatic convenience wrappers may perform work that a low-level review should inspect.

Limit unnecessary processing

Read only the output required by the protocol when possible and validate its shape. Choose bounded failure reporting instead of blindly forwarding unlimited diagnostic content.

Test hostile outputs

Include large success and failure payloads in local tests. Verify that failure handling itself does not violate accounting or leave essential cleanup unfinished.

Follow the execution

Caller requests a short result
Target supplies a very large byte buffer
Caller copies all bytes → memory expansion and copy cost

Bound work according to the actual interface need.

A local conceptual trace with explicit assumptions; this is not a trace of a live transaction.

QUICK CHECK · NO PRESSURE

Can failure-message copying consume significant caller gas?

Your progress stays in this browser.
Keep exploring the original referenceethereum.org ↗

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