Integer Overflow (Web Applications)
Reading time: 5 minutes
tip
AWS Hacking'i öğrenin ve pratik yapın:HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking'i öğrenin ve pratik yapın: HackTricks Training GCP Red Team Expert (GRTE)
Azure Hacking'i öğrenin ve pratik yapın:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks'i Destekleyin
- abonelik planlarını kontrol edin!
- 💬 Discord grubuna veya telegram grubuna katılın ya da Twitter'da bizi takip edin 🐦 @hacktricks_live.**
- Hacking ipuçlarını paylaşmak için HackTricks ve HackTricks Cloud github reposuna PR gönderin.
This page focuses on how integer overflows/truncations can be abused in web applications and browsers. For exploitation primitives inside native binaries you can continue reading the dedicated page:
{{#ref}}
../../binary-exploitation/integer-overflow-and-underflow.md {{#endref}}
1. Why integer math still matters on the web
Modern yığınlardaki çoğu business-logic memory-safe dillerde yazılmış olsa da, altında yatan runtime (veya üçüncü taraf kütüphaneler) sonunda C/C++ ile implement edilir. Kullanıcı kontrollü sayılar buffer tahsisi, offset hesaplama veya uzunluk doğrulamaları için kullanıldığında, 32-bit veya 64-bit wrap-around görünürde zararsız bir parametreyi out-of-bounds read/write, bir logic bypass veya DoS'e dönüştürebilir.
Tipik saldırı yüzeyi:
- Numeric request parameters – klasik id, offset veya count alanları.
- Length / size headers – Content-Length, WebSocket frame length, HTTP/2 continuation_len, vb.
- File-format metadata parsed server-side or client-side – image dimensions, chunk sizes, font tables.
- Language-level conversions – signed↔unsigned casts in PHP/Go/Rust FFI, JS Number → int32 truncations inside V8.
- Authentication & business logic – coupon value, price veya balance hesaplamaları sessizce overflow olduğunda.
2. Recent real-world vulnerabilities (2023-2025)
Year | Component | Root cause | Impact |
---|---|---|---|
2023 | libwebp – CVE-2023-4863 | 32-bit multiplication overflow when computing decoded pixel size | Triggered a Chrome 0-day (BLASTPASS on iOS), allowed remote code execution inside the renderer sandbox. |
2024 | V8 – CVE-2024-0519 | Truncation to 32-bit when growing a JSArray leads to OOB write on the backing store | Remote code execution after a single visit. |
2025 | Apollo GraphQL Server (unreleased patch) | 32-bit signed integer used for first/last pagination args; negative values wrap to huge positives | Logic bypass & memory exhaustion (DoS). |
3. Testing strategy
3.1 Boundary-value cheat-sheet
Bir integer beklendiği her yere extreme signed/unsigned values gönderin:
-1, 0, 1,
127, 128, 255, 256,
32767, 32768, 65535, 65536,
2147483647, 2147483648, 4294967295,
9223372036854775807, 9223372036854775808,
0x7fffffff, 0x80000000, 0xffffffff
Diğer faydalı formatlar:
- Hex (0x100), octal (0377), scientific (1e10), JSON big-int (9999999999999999999).
- Çok uzun rakam dizileri (>1kB) — özel parsers'ı tetiklemek için.
3.2 Burp Intruder şablonu
§INTEGER§
Payload type: Numbers
From: -10 To: 4294967300 Step: 1
Pad to length: 10, Enable hex prefix 0x
3.3 Fuzzing kütüphaneleri ve çalışma zamanları
- AFL++/Honggfuzz — ayrıştırıcı etrafında libFuzzer harness ile (ör. WebP, PNG, protobuf).
- Fuzzilli — dilbilgisine duyarlı fuzzing ile JavaScript engine'lerini hedefleyerek V8/JSC integer truncations'ı hedefler.
- boofuzz — ağ protokolü fuzzing'i (WebSocket, HTTP/2) ile uzunluk alanlarına odaklanır.
4. Exploitation patterns
4.1 Logic bypass in server-side code (PHP example)
$price = (int)$_POST['price']; // expecting cents (0-10000)
$total = $price * 100; // ← 32-bit overflow possible
if($total > 1000000){
die('Too expensive');
}
/* Sending price=21474850 → $total wraps to ‑2147483648 and check is bypassed */
4.2 Heap overflow via image decoder (libwebp 0-day)
The WebP lossless decoder multiplied image width × height × 4 (RGBA) inside a 32-bit int. A crafted file with dimensions 16384 × 16384 overflows the multiplication, allocates a short buffer and subsequently writes ~1GB of decompressed data past the heap – leading to RCE in every Chromium-based browser before 116.0.5845.187.
4.3 Browser-based XSS/RCE chain
- V8'deki Integer overflow rastgele read/write sağlar.
- Sandbox'tan kaçmak için ikinci bir bug kullanın veya native APIs çağırıp bir payload bırakın.
- Payload daha sonra origin bağlamına zararlı bir script enjekte eder → stored XSS.
5. Savunma yönergeleri
- Use wide types or checked math – örn., size_t, Rust checked_add, Go math/bits.Add64.
- Validate ranges early: aritmetik işlemden önce iş alanı dışındaki herhangi bir değeri reddedin.
- Enable compiler sanitizers: -fsanitize=integer, UBSan, Go race detector.
- Adopt fuzzing in CI/CD – coverage feedback ile boundary corpora'yı birleştirin.
- Stay patched – browser integer overflow hataları genellikle haftalar içinde istismar edilir.
References
- NVD CVE-2023-4863 – libwebp Heap Buffer Overflow
- Google Project Zero – "Understanding V8 CVE-2024-0519"
tip
AWS Hacking'i öğrenin ve pratik yapın:HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking'i öğrenin ve pratik yapın: HackTricks Training GCP Red Team Expert (GRTE)
Azure Hacking'i öğrenin ve pratik yapın:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks'i Destekleyin
- abonelik planlarını kontrol edin!
- 💬 Discord grubuna veya telegram grubuna katılın ya da Twitter'da bizi takip edin 🐦 @hacktricks_live.**
- Hacking ipuçlarını paylaşmak için HackTricks ve HackTricks Cloud github reposuna PR gönderin.