N-day patch diffing to exploit
When it applies
A vendor shipped a fix but no details: a CVE advisory says "out-of-bounds write in component
X" with no PoC, a Patch Tuesday drop needs triage, or a Linux distro backport may be
incomplete on some branch. The goal is to recover what the patch fixed and prove the bug
against the unpatched build. Weaponizing an N-day is only legitimate against in-scope,
authorized targets (a program that accepts it, an engagement, your own lab) — confirm with
tradecraft-scope-roe and record it in scope.txt.
Why it works
A security patch is a confession. The added bounds check, lock, zeroing, or refcount tells you
exactly which invariant the old code violated — and the unpatched binary still violates it.
Diff the two builds, filter to functions that changed moderately (identical = untouched,
completely different = new feature), and the fix pattern maps almost one-to-one onto a bug
class you can then trigger.
| The patch adds... | Likely bug class |
|---|---|
| if (a + b < a) / __builtin_add_overflow | integer overflow |
| KeAcquireSpinLock / mutex_lock | race condition (TOCTOU / double-free) |
| if (idx >= MAX) / if (len > buf_size) | OOB read / write |
| RtlZeroMemory / memset(struct, 0, ...) | uninitialized-memory info leak |
| InterlockedDecrement + refcount check | UAF / refcount error |
| ProbeForRead / ProbeForWrite / access_ok | unvalidated user-mode pointer |
| SeAccessCheck / capability check | missing authorization |
| removed / tightened IOCTL codes | attack-surface reduction — study the old interface |
Method
- Get the before/after binaries. Windows: download the MSU for build N (patched) and N-1
from the Microsoft Update Catalog, unpack with expand.exe. Linux: apt download the two
kernel/package versions and dpkg-deb -x / rpm2cpio them. Third-party software: grab the