Back to course

Web3 Security: Integer Overflows

Rust for Systems & Web3 Security

The Most Common Exploit

In old versions of Rust or with specific flags, 255u8 + 1 could wrap around to 0. In a financial contract, this is a disaster.

Solution: Always use checked_add, checked_sub, or enable overflow checks in your Cargo.toml.