A calculation whose result does not fit its integer type. In Rust release builds it wraps around silently unless overflow checks are on, so a balance or a price can end up wrong without any error.
Why it matters
Token amounts, fees, rewards and prices are all integer maths. An overflow or a rounding error can mint more than intended, zero out a fee or lock funds, and it often shows only with extreme inputs that normal tests never use.
What to check
- Ask whether overflow checks are enabled in the release profile and whether the code uses checked arithmetic.
- Ask how rounding is handled in fee and reward calculations, and which side it favours.
How it works in practice
Rust only panics on overflow when overflow checks are on. Anchor projects normally set overflow-checks to true in the release profile, and careful code also uses checked_add, checked_sub and checked_mul and returns an error on failure.
Fee and reward formulas also need a rounding rule. Rounding in the user’s favour on every call can drain a pool slowly, so the rounding direction is chosen on purpose.
Common mistakes
- Leaving overflow checks off in the release profile and assuming debug tests prove safety.
- Casting between integer sizes, for example u128 to u64, without a check.
- Multiplying before dividing in a way that overflows, or dividing first and losing precision.
Related terms
- ProgramSolana’s term for a smart contract: executable code deployed to an account.
- AnchorThe most widely used framework for writing Solana programs in Rust.
- Audit (smart contract audit)An independent security review of a program at a specific commit, usually by a specialised firm, that reports vulnerabilities and recommendations before launch.
- Fuzz testingAutomated testing that sends a program large numbers of random or generated inputs and instruction sequences to find crashes and broken invariants that hand-written tests miss.
Guides
- Solana Anchor security checklist: 16 code checks before your auditA practical Anchor security checklist: signers, has_one, UncheckedAccount, PDA seeds, init_if_needed, closing accounts, token constraints, CPIs, math and remaining_accounts.
- Anchor vs native Rust for Solana programs: how to chooseAnchor or native Rust for your Solana program? The real trade-offs in safety, speed of development, compute usage, tooling and hiring, and when each choice makes sense.
- How to choose a Solana smart contract auditor: a practical checklistWhat actually matters when picking a Solana auditor: Anchor and native Rust experience, methodology, scope, timelines, red flags in quotes and what a good report looks like.
Describe your project in plain English. Smart Match suggests verified Solana providers with a reason for each match. Free for teams.
Get matched →