Rules › Anchor (Rust)
overflow-checks not enabled for release builds
Release builds wrap on overflow unless overflow-checks = true is set in [profile.release].
Why it matters
Rust checks integer overflow in debug builds but wraps silently in release builds unless the profile says otherwise. Solana programs ship release builds. Anchor's templates set overflow-checks = true under [profile.release]; if it's missing, a balance that underflows becomes enormous instead of failing.
Vulnerable
[profile.release]
lto = "fat"
codegen-units = 1
Fixed
[profile.release]
overflow-checks = true
lto = "fat"
codegen-units = 1
What other tools call it
| Tool | Detector or reference |
|---|---|
| Clippy | arithmetic_side_effects |
Check your code
Paste a contract into the in-browser checker, or let the Claude Code plugin scan before every deploy. The quick check for this rule is a pattern match: treat a hit as "look here", and a miss as no guarantee.
Related rules
- Unchecked account without a /// CHECK: note
- Authority account that isn't a Signer
- CPI to a program the caller chooses
- Account data deserialized without an owner check
- init_if_needed (reinitialization risk)
- Account closed by draining lamports by hand
Static analysis finds known bug classes; it can't prove code is safe and isn't an audit. Get a professional audit before deploying code that will hold value.