Rust Arithmetic Integer Overflow
Description
This detector identifies potential integer overflow vulnerabilities in Rust applications using the Actix Web framework. Integer overflow occurs when arithmetic operations result in values that exceed the data type's maximum capacity, potentially leading to unexpected behavior, security bypasses, or denial of service attacks.
Detection Strategy
• Reports vulnerabilities only in Rust code that imports the actix_web library
• Scans execution blocks within the code for arithmetic operations that could cause integer overflow
• Flags code patterns where mathematical operations may exceed integer type limits without proper bounds checking
Vulnerable code example
use actix_web::{get, web, HttpResponse};
#[get("/price/{quantity}")]
async fn calculate_price(path: web::Path<u32>) -> HttpResponse {
let quantity = path.into_inner();
let unit_price: u32 = 100;
// VULNERABLE: unchecked multiplication can overflow in release builds...✅ Secure code example
use actix_web::{get, web, HttpResponse};
#[get("/price/{quantity}")]
async fn calculate_price(path: web::Path<u32>) -> HttpResponse {
let quantity = path.into_inner();
let unit_price: u32 = 100;
// SAFE: checked_mul returns None on overflow instead of wrapping...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.