Skip to main content

Overflow check

Description

Checks that overflow-checks is enabled in the [profile.release] section of the Cargo.toml.

Integer overflow will trigger a panic in debug builds or will wrap in release mode. Division by zero will cause a panic in either mode. In some applications one wants explicitly checked, wrapping or saturating arithmetic.

Exploit Scenario

Consider the following Cargo.toml, in a Soroban contract:

[profile.release]
overflow-checks = false

Problems can arise if overflow-checks is disabled.

The vulnerable code example can be found here.

Remediation

[profile.release]
overflow-checks = true

The remediated code example can be found here.