Skip to content
Back to skills

Integer Overflow

ASecurity

Integer overflow/underflow bugs: width conversion, mul/add wrap, size calc to alloc/copy, signedness, exploits to heap/stack corruption.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 17, 2026
code-qualitygoc++api

Works with

  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned October 17, 2026

npx -y skills add NetVar1337/agent-skill-canon --skill integer-overflow --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Integer Overflow?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Integer Overflow
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/netvar1337-integer-overflow/badge)](https://www.skillsdirectory.com/skills/netvar1337-integer-overflow)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: integer-overflow
description: "Integer overflow/underflow bugs: width conversion, mul/add wrap, size calc to alloc/copy, signedness, exploits to heap/stack corruption."
version: 1.0.0
license: GPL-3.0-or-later
metadata:
  package: unleash-skills
  author: NetVar1337/unleash
  category: exploit
  triggers:
    - "integer overflow"
    - "integer underflow"
    - "wraparound"
    - "size_t mul"
    - "signedness bug"
---

# Integer overflow & underflow

## Bug patterns
1. **Add/mul wrap** before `malloc(n * size)` → small alloc, large copy
2. **Truncation** `size_t` → `uint32`/`uint16` on boundary checks
3. **Signed/unsigned mix** — negative length passes `< max` then huge `size_t`
4. **Off-by-one** length including/excluding NUL
5. **Custom saturating math done wrong** (checked add that doesn't)

## Underflow specifics
- `len - hdr` when `len < hdr` → enormous unsigned
- Loop `for (i = n-1; i >= 0; i--)` with unsigned `i`
- Refcount `--` at zero → free-while-live / UAF setup

## From integer to memory corruption
```
bad_size = wrap(count * elem)
p = alloc(bad_size)          # small
copy(src, p, count * elem)   # large → heap overflow
```
Also: index OOB via wrapped index; stack alloc via VLAs/`alloca` with wrapped size.

## Hunting
- CodeQL/semgrep: mul then alloc; unchecked casts
- Diff size checks vs copy lengths
- Fuzz with maxed integers (`0xffffffff`, `1<<31`, `0`)

## Exploit notes
- Prefer stable heap layout after wrap-induced overflow
- Record exact widths (32 vs 64) per build
- On C++ `size_t`/`int` APIs (Win32 `int cb`) watch 2GB boundary

## Pair with
`heap-overflow`, `heap-exploitation`, `stack-buffer-overflow`, `c-review`.

Files in this skill

  • SKILL.md1.6 KB
  • agents/openai.yaml43 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.