Assembly Explained in Detail
Assembly lets Solidity code use lower-level Yul or EVM operations. It can be useful for performance or custom encoding, but it bypasses many compiler checks.
Assembly can directly read calldata, write memory, write storage, make calls, and return or revert raw data.
Smart contract example
assembly {
let ptr := mload(0x40)
mstore(ptr, 0x1234)
}
Small mistakes in pointer or offset logic can corrupt memory.
Assembly in Auditing
Assembly is a high-risk review area because the compiler cannot protect as much. Bugs can hide in manual ABI encoding, storage-slot math, return-data handling, and low-level calls.
Auditors review assembly line by line.
Red flags in code
-
Manual calldata parsing lacks length checks.
-
Free memory pointer is corrupted.
-
sstorewrites to computed slots without clear proof. -
Return or revert data is copied with unchecked sizes.
-
Assembly calls use user-controlled targets or calldata.
How to test or review it
-
Fuzz lengths, offsets, and boundary values.
-
Compare assembly behavior against a simple Solidity reference.
-
Check memory pointer and scratch-space usage.
-
Review storage slot calculations.
-
Test malformed calldata and revert bubbling.
Keep learning this topic
Calldata
Calldata is the read-only input data sent to a contract call, usually containing the function selector and ABI-encoded arguments.
Storage Slot
A storage slot is a 32-byte indexed location in EVM contract storage used to hold state variables and derived storage data.
Low-Level Call
A low-level call is a Solidity call such as call, delegatecall, staticcall, or send that returns success and data instead of using typed function checks.
Practice this in real audit scenarios
Definitions help, but auditors need reps. SCH turns concepts like Assembly into exploit labs, code review habits, and report-writing practice.
Start the free trial or see the full smart contract auditing course.