Rules › Anchor (Rust)

overflow-checks not enabled for release builds

mediumAnchor (Rust)Rule rust-overflow-checks-off

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

ToolDetector or reference
Clippyarithmetic_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.

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.