How clean is your code? Dirty Bits in Solidity
summary
Shows that dirty high-order bits in Solidity values make inline assembly produce different results under legacy pipeline vs via-IR, with ABI decoder v1 masking dirty inputs while ABI decoder v2 reverts; finds ~61% of sampled mainnet contracts still use the legacy pipeline. Introduces a source-and-sink model for finding bugs, points to an open via-IR compiler issue that fails to clean words (causing out‑of‑bounds panics), demonstrates incorrect signed-value cleanup, and recommends cleaning at both assembly boundaries and testing the pipeline shipped.
AI-written summary · about
chapters (13)
- 0:00Introduction and background
- 1:50Dirty bits in Solidity
- 3:58Why compilers leave dirty bits
- 6:24Legacy vs Yul pipeline differences
- 7:28Decoder versions and dirty bits
- 8:31Soulmate token transfer case
- 10:39Function vs fallback decoder behavior
- 11:21Sources and sinks of dirty bits
- 12:45Risk levels by source-sink pairs
- 13:26Compiler bug in Yul pipeline
- 14:30Washing programs in assembly
- 15:11Cleaning tips and best practices
- 15:54Summary and Q&A
