Overflow / Underflow de Inteiro
A class of arithmetic vulnerabilities where an integer computation produces a result outside the bounds of its fixed-width type, wrapping around silently in Rust's release builds (since Rust panics on overflow only in debug mode), yielding an incorrect value that can corrupt token balances, borrow limits, or access control counters. For example, subtracting a larger u64 from a smaller one wraps to near u64::MAX (~1.8 × 10^19), which could be interpreted as an enormous balance. Solana programs must use Rust's checked_add, checked_sub, checked_mul, and checked_div methods (or the saturating_* / wrapping_* variants with deliberate intent) on all financial arithmetic to eliminate this class of bugs.
Integer overflow é quando uma soma ultrapassa o valor máximo de um tipo e 'dá a volta' — 255 + 1 = 0 em u8. Em programas financeiros, isso pode criar tokens do nada.
Use sempre aritmética checked em Rust (`checked_add`, `checked_sub`, `checked_mul`) e retorne erro explícito em vez de deixar overflow silencioso causar dano.
Usar `as u64` para conversões sem verificar se o valor cabe. Truncamento silencioso em casts pode ser tão perigoso quanto overflow em lógica financeira.
Sua exploração
0 termos visitados no total