inline-assembly
Skill36 starsChanged 5 months agoMITView on GitHub
Detect bugs in inline Yul / assembly — manual memory mismanagement, free-memory-pointer corruption, return-data manipulation, missing return-data-size checks, dirty-bits in narrow types. Activate on any `assembly { … }` block, Yul code, Solady-style assembly usage.
In this repository44 other files it gives its agents.
- access-controlSkill
- approval-issuesSkill
- caching-and-incrementalSkill
- centralization-riskSkill
- confidence-scoringSkill
- cosmwasmSkill
- cross-chain-messagingSkill
- cross-contract-stateSkill
- delegatecall-risksSkill
- diamond-eip2535Skill
- dos-vectorsSkill
- erc1271-contract-signaturesSkill
- erc4337-account-abstractionSkill
- erc4626-inflationSkill
- false-positive-feedback-loopSkill
- fee-on-transferSkill
- flash-loan-attacksSkill
- initializationSkill
- integer-issuesSkill
- intents-erc7683Skill
- known-good-comparisonSkill
- liquidation-cascadeSkill
- mev-frontrunningSkill
- mev-pbsSkill
- multi-pass-self-critiqueSkill
- oracle-manipulationSkill
- oracle-redundancySkill
- permit2-patternsSkill
- pragma-and-addressesSkill
- progress-and-streamingSkill
- reentrancySkill
- restaking-eigenlayerSkill
- selfdestruct-eip6780Skill
- signature-malleabilitySkill
- signature-replaySkill
- solana-anchorSkill
- storage-layoutSkill
- stylus-rustSkill
- token-compatibilitySkill
- tx-context-misuseSkill
- unchecked-callsSkill
- ve-lock-governanceSkill
- vyper-specificSkill
- zk-verifier-bugsSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 26
After writing memory, update mload(0x40) to past the write.
- Very specific: line 39
Check returndatasize() before copying.
- Distinctive: line 80
Prefer audited primitives (OZ, Solady) — don't roll your own assembly.
- Distinctive: line 81
Document every assembly block: invariants, memory map, why.
- Very specific: line 82
Always update mload(0x40) after writes.
- Very specific: line 83
Check returndatasize() before returndatacopy.
- Distinctive: line 85
Test with edge-case inputs (zero-length return, oversize return, dirty high bits).
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Inline assembly / Yul auditor
When this applies
- Any
assembly { … }block - Pure Yul contracts
- Solady's heavy use of optimized assembly
- Custom delegatecall wrappers, manual memory copy, custom signature verifiers
- Gas-optimization-driven assembly substitutions of Solidity primitives
Detection patterns
Free-memory-pointer not updated after allocation (HIGH)
assembly {
let ptr := mload(0x40)
mstore(ptr, value)
// ← didn't bump 0x40, next allocation corrupts
}After writing memory, update mload(0x40) to past the write.
Memory clobbering via reused scratch space (HIGH)
Yul scratch is 0x00-0x3F. External calls / Solidity assignments may overwrite. Don't store across foreign-code boundaries.
Return data not size-checked (HIGH)
assembly {
let ok := call(gas(), target, 0, in, insz, 0, 32)
returndatacopy(0, 0, 32)
let r := mload(0) // ← if target returned < 32 bytes, r has trailing memory garbage
}Check returndatasize() before copying.
Dirty high bits in narrow types (HIGH)
A uint8 read from calldata via calldataload has the high 248 bits unmasked. Mask with and(..., 0xff) before comparing.
Returning attacker-controlled memory (HIGH)
assembly { return(0, calldatasize()) } // ← returns calldata; if function spec says bytes32, parsers blow upMishandling 0x40 / 0x60 (FMP and zero slot) (HIGH)
Writing to 0x60 (zero slot) is a known footgun — that slot must stay zero. Solidity uses it in mappings.
mstore to slot 0/0x20 not cleared after a call (MEDIUM-HIGH)
Reused scratch leaks data across functions.
Loop bounds in assembly without checks (HIGH)
Easy to write infinite loops or array-bound-violators.
Wrong opcode (callcode, suicide, gas costs) (HIGH)
Legacy opcodes still parseable but deprecated. callcode is the wrong delegatecall; suicide is selfdestruct.
Address pointers larger than 20 bytes (HIGH)
address masked at 20 bytes; assembly users sometimes treat as full 32 bytes and leave dirty bits.
Severity rubric
| Pattern | Severity |
| Free-memory-pointer corruption | High |
| Unchecked returndatasize | High |
| Dirty high bits on narrow type | High |
| Wrong/legacy opcode | High |
| Writes to 0x60 (zero slot) | High |
| Reused scratch across foreign call | High |
| Assembly returning misformatted ABI data | High |
| Pure-Yul math with no overflow proof | High |
| Comment-less assembly block in production code | Low (maintainability) |
Remediation patterns
- Prefer audited primitives (OZ, Solady) — don't roll your own assembly.
- Document every assembly block: invariants, memory map, why.
- Always update
mload(0x40)after writes; explicitly zero scratch after use. - Check
returndatasize()beforereturndatacopy. - Mask narrow types:
and(x, 0xff)foruint8,and(x, 0xffff)foruint16, etc. - Test with edge-case inputs (zero-length return, oversize return, dirty high bits).
False-positive notes
- Single-line read of fixed slot (e.g.
chainid(),gasprice(),caller()) is safe. - Solady's published assembly libraries are audited; using them as-is is fine — verify version pinning.
Related
- [[assembly-auditor]] (subagent)
- [[unchecked-calls]]
- [[storage-layout]]
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

