Integer Overflow (Web Applications)
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
์ด ํ์ด์ง๋ integer overflows/truncations๊ฐ ์น ์ ํ๋ฆฌ์ผ์ด์ ๊ณผ ๋ธ๋ผ์ฐ์ ์์ ์ด๋ป๊ฒ ์ ์ฉ๋ ์ ์๋์ง์ ์ด์ ์ ๋ง์ถฅ๋๋ค. ๋ค์ดํฐ๋ธ ๋ฐ์ด๋๋ฆฌ ๋ด๋ถ์ exploitation primitives์ ๋ํด์๋ ์ ์ฉ ํ์ด์ง๋ฅผ ๊ณ์ ์ฝ์ผ์ธ์:
{{#ref}}
../../binary-exploitation/integer-overflow-and-underflow.md {{#endref}}
1. Why integer math still matters on the web
๋๋ถ๋ถ์ ๋น์ฆ๋์ค ๋ก์ง์ด ์ต์ ์คํ์์ memory-safe ์ธ์ด๋ก ์์ฑ๋๋๋ผ๋, ๊ธฐ์ ๋ฐํ์(๋๋ ์๋ํํฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ)์ ๊ฒฐ๊ตญ C/C++๋ก ๊ตฌํ๋ฉ๋๋ค. ์ฌ์ฉ์ ์ ์ด ์ซ์๊ฐ ๋ฒํผ ํ ๋น, ์คํ์ ๊ณ์ฐ, ๋๋ ๊ธธ์ด ๊ฒ์ฌ์ ์ฌ์ฉ๋ ๋, 32-bit ๋๋ 64-bit์ ๋ํ(๋ํผ์ด๋ผ์ด๋)์ ์ธ๊ฒฌ์ ๋ฌดํดํ ํ๋ผ๋ฏธํฐ๋ฅผ ๋ฒ์๋ฅผ ๋ฒ์ด๋ ์ฝ๊ธฐ/์ฐ๊ธฐ, ๋ ผ๋ฆฌ ์ฐํ ๋๋ DoS๋ก ๋ฐ๊ฟ ์ ์์ต๋๋ค.
์ผ๋ฐ์ ์ธ ๊ณต๊ฒฉ ํ๋ฉด:
- Numeric request parameters โ ์ ํ์ ์ธ id, offset, ๋๋ count ํ๋.
- Length / size headers โ Content-Length, WebSocket frame length, HTTP/2 continuation_len ๋ฑ.
- File-format metadata parsed server-side or client-side โ ์ด๋ฏธ์ง ํฌ๊ธฐ, ์ฒญํฌ ํฌ๊ธฐ, ํฐํธ ํ ์ด๋ธ.
- Language-level conversions โ PHP/Go/Rust FFI์์์ signedโunsigned ์บ์คํธ, V8 ๋ด๋ถ์ JS Number โ int32 truncations.
- Authentication & business logic โ ์ฟ ํฐ ๊ฐ, ๊ฐ๊ฒฉ ๋๋ ์๊ณ ๊ณ์ฐ์์ ์กฐ์ฉํ ๋ฐ์ํ๋ overflow.
2. Recent real-world vulnerabilities (2023-2025)
| ์ฐ๋ | ์ปดํฌ๋ํธ | ๊ทผ๋ณธ ์์ธ | ์ํฅ |
|---|---|---|---|
| 2023 | libwebp โ CVE-2023-4863 | ๋์ฝ๋ฉ๋ ํฝ์ ํฌ๊ธฐ๋ฅผ ๊ณ์ฐํ ๋ ๋ฐ์ํ 32-bit multiplication overflow | Chrome 0-day(BLASTPASS on iOS)๋ฅผ ํธ๋ฆฌ๊ฑฐํ๊ณ , renderer sandbox ๋ด๋ถ์์ remote code execution๋ฅผ ํ์ฉํ์ต๋๋ค. |
| 2024 | V8 โ CVE-2024-0519 | JSArray๋ฅผ ํ์ฅํ ๋ 32-bit๋ก์ truncation์ด backing store์ ๋ํ OOB write๋ก ์ด์ด์ง | ๋จ ํ ๋ฒ์ ๋ฐฉ๋ฌธ์ผ๋ก Remote code execution์ด ๋ฐ์ํ์ต๋๋ค. |
| 2025 | Apollo GraphQL Server (unreleased patch) | first/last pagination args์ 32-bit signed integer๋ฅผ ์ฌ์ฉ; ์์ ๊ฐ์ด ํฐ ์์๋ก ๋ฉ๋ฉ๋๋ค | Logic bypass & memory exhaustion (DoS). |
3. Testing strategy
3.1 Boundary-value cheat-sheet
์ ์๊ฐ ์์๋๋ ๋ชจ๋ ๊ณณ์ extreme signed/unsigned values๋ฅผ ์ ์กํ์ธ์:
-1, 0, 1,
127, 128, 255, 256,
32767, 32768, 65535, 65536,
2147483647, 2147483648, 4294967295,
9223372036854775807, 9223372036854775808,
0x7fffffff, 0x80000000, 0xffffffff
๋ค๋ฅธ ์ ์ฉํ ํ์:
- Hex (0x100), octal (0377), scientific (1e10), JSON big-int (9999999999999999999).
- ๋งค์ฐ ๊ธด ์ซ์ ๋ฌธ์์ด(>1kB)๋ก ์ปค์คํ ํ์๋ฅผ ํธ๋ฆฌ๊ฑฐํ๊ธฐ ์ํด.
3.2 Burp Intruder ํ ํ๋ฆฟ
ยงINTEGERยง
Payload type: Numbers
From: -10 To: 4294967300 Step: 1
Pad to length: 10, Enable hex prefix 0x
3.3 Fuzzing ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ฐ ๋ฐํ์
- AFL++/Honggfuzz with libFuzzer ํ๋์ค๋ก ํ์๋ฅผ ๋์์ผ๋ก (์: WebP, PNG, protobuf).
- Fuzzilli โ ๋ฌธ๋ฒ ์ธ์ํ fuzzing์ผ๋ก JavaScript ์์ง์ V8/JSC ์ ์ ์ ๋จ์ ๊ณต๋ต.
- boofuzz โ ๋คํธ์ํฌ ํ๋กํ ์ฝ fuzzing (WebSocket, HTTP/2)์์ ๊ธธ์ด ํ๋์ ์ง์ค.
4. Exploitation patterns
4.1 Logic bypass in ์๋ฒ์ธก ์ฝ๋ (PHP ์์ )
$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 ์ด๋ฏธ์ง ๋์ฝ๋ (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 ๋ธ๋ผ์ฐ์ ๊ธฐ๋ฐ XSS/RCE ์ฒด์ธ
- Integer overflow in V8๋ arbitrary read/write๋ฅผ ๊ฐ๋ฅํ๊ฒ ํ๋ค.
- ๋ ๋ฒ์งธ ๋ฒ๊ทธ๋ก sandbox๋ฅผ ํ์ถํ๊ฑฐ๋ native APIs๋ฅผ ํธ์ถํด payload๋ฅผ ๋ฐฐ์นํ๋ค.
- ๊ทธ payload๋ origin context์ ์ ์ฑ ์คํฌ๋ฆฝํธ๋ฅผ ์ฃผ์ โ stored XSS.
5. ๋ฐฉ์ด ์ง์นจ
- Use wide types or checked math โ e.g., size_t, Rust checked_add, Go math/bits.Add64.
- Validate ranges early: ์ฐ์ ์ฐ์ฐ ์ ์ ๋น์ฆ๋์ค ๋๋ฉ์ธ ๋ฐ์ ๊ฐ์ ๊ฑฐ๋ถํ๋ผ.
- Enable compiler sanitizers: -fsanitize=integer, UBSan, Go race detector.
- Adopt fuzzing in CI/CD โ coverage feedback๊ณผ boundary corpora๋ฅผ ๊ฒฐํฉํ๋ผ.
- Stay patched โ ๋ธ๋ผ์ฐ์ ์ integer overflow ๋ฒ๊ทธ๋ ๋ช ์ฃผ ๋ด์ ์์ฃผ ์ ์ฉ๋๋ค.
์ฐธ๊ณ ์๋ฃ
- NVD CVE-2023-4863 โ libwebp Heap Buffer Overflow
- Google Project Zero โ โUnderstanding V8 CVE-2024-0519โ
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


