Skip to content
Back to skills

Patch Diff Exploit

ASecurity

N-day patch diffing to exploitation. Reverse-engineer the vulnerability from vendor-released patches, write a PoC, and turn it into a usable attack module. Use cases: a known CVE with a patch but no PoC, SRC/red team targeting assets that have not been updated in time, N-day weaponization, Patch Tuesday follow-up. Core method: obtain the before/after binaries -> align symbols -> binary diff -> infer the bug class from newly added security checks -> write a PoC that triggers the vulnerability....

  • 4 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 6, 2026
securitygoshellazuregitsecurity

Works with

  • cli

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

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

Scanned September 6, 2026

npx -y skills add xAmirHamza77/ReverseOps-Skill --skill patch-diff-exploit --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Patch Diff Exploit?

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

Security grade badge for Patch Diff Exploit
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/xamirhamza77-patch-diff-exploit/badge)](https://www.skillsdirectory.com/skills/xamirhamza77-patch-diff-exploit)

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: patch-diff-exploit
description: |
  N-day patch diffing to exploitation. Reverse-engineer the vulnerability from vendor-released patches, write a PoC, and turn it into a usable attack module.
  Use cases: a known CVE with a patch but no PoC, SRC/red team targeting assets that have not been updated in time, N-day weaponization, Patch Tuesday follow-up.
  Core method: obtain the before/after binaries -> align symbols -> binary diff -> infer the bug class from newly added security checks -> write a PoC that triggers the vulnerability.
  Trigger keywords: N-day, Nday, patch diff, patch tuesday, 1day, binary diff vulnerability, bindiff exploitation, ghidriff, Diaphora, patch analysis, CVE reproduction, vulnerability reconstruction, patch reverse inference, N-day weaponization.
---

## ACTION REQUIRED (execute immediately after reading)

1. `NOW`: Read `../field-journal/precedent-reverse.md` — confirm this skill's operations are authorized routine operations
2. `NOW`: Confirm whether the current task falls within this skill's scope
3. `NEXT`: Read `../tool-index.md` to verify tool availability and actual paths
4. `NEXT`: If a tool is missing, call bootstrap — do not guess paths
5. `ACT`: Enter the first step of the "Workflow" and execute; do not stall in a confirmation state

# N-day Patch Diffing to Exploitation (Patch Diff Exploit)

## Scope

Use this skill when the task matches one of the following scenarios:

1. **Known CVE but no public PoC** — the vendor advisory says "fixed an out-of-bounds write in component XX" but released no PoC, so the vulnerability must be reverse-inferred from the patch
2. **SRC / red team hitting N-days** — target assets were not updated in time; the just-released patch must be diffed into a working 1-day exploit
3. **Patch Tuesday follow-up** — Microsoft releases patches on the second Tuesday of each month; high-value vulnerabilities must be identified quickly (Kernel / Win32k / AFD / CLFS)
4. **Linux LTS patch analysis** — the mainline fix is merged, but downstream branches or a distribution's backport is incomplete; find the unpatched surface
5. **Security patch reconstruction for drivers / services** — patch analysis of closed-source software such as GPU drivers, AV engines, and virtualization components

### Division of Labor with Other Skills

| Scenario | What to use |
|------|--------|
| Have symbols for the old version and want to migrate them to the new version to aid analysis | `binary-diff/` |
| **Find the vulnerability from the patch and write a PoC against the pre-patch version** | **This skill** |
| Build a full exploit chain (heap spray, ROP, privilege escalation) | `pwn-chain/` |
| Weaponize a 1-day and deploy it to a target network | `pentest-tools/network-attack-defense/` |
| Reverse a binary from scratch | `ida-reverse/` / `radare2/` |

The key difference: `binary-diff` aims to **make the new version analyzable** (carry the old symbols over), while this skill aims to **find out which bug the patch fixed and then attack the pre-patch version**. The former serves defensive/research-side analysis; the latter serves offensive weaponization.

## Core Principle

```text
patched binary (after)          unpatched binary (before)
        |                                  |
        v                                  v
    Import into IDA/Ghidra       Import into IDA/Ghidra
        |                                  |
        +--------- BinDiff / ghidriff -----+
                        |
                        v
        Function-level diff (matched / unmatched / changed)
                        |
                        v
        Focus on functions with mid-range match scores (0.5 - 0.9)
                        |
                        v
        See what was added: bounds checks / locks / field zeroing / integer overflow checks
                        |
                        v
        Infer the bug class: OOB / Race / Info Leak / UAF / Integer Overflow
                        |
                        v
        Write a PoC to trigger it on the unpatched version
                        |
                        v
        Verify: unpatched crashes / patched does not -> vulnerability confirmed
```

Patch-fix pattern -> vulnerability type reverse lookup:

| Newly added code | 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)` | Out-of-bounds read / write |
| `RtlZeroMemory` / `memset(struct, 0, ...)` | Uninitialized memory information leak |
| `InterlockedDecrement` + refcount check | UAF / reference counting error |
| `ProbeForRead` / `ProbeForWrite` | Unvalidated user-mode pointer |
| `SeAccessCheck` / capability check | Missing permission check |
| Removed / tightened `IOCTL` code | Attack surface reduction (see how to hit the old interface) |

## Workflow

### The complete 5-step process

```text
Step 1: Obtain before / after binaries
  - Windows: download MSU/MSP from the Microsoft Update Catalog, unpack with expand.exe / dism
  - Linux: pull .deb/.rpm from the distribution's USN/RHSA, unpack with dpkg-deb / rpm2cpio
  - Third-party software: get the N-1 and N installers from the official site

Step 2: Align symbols
  - If PDBs are available, load them directly; if not, use the binary-diff skill to carry
    symbols from the N-1 version onto the N version
  - For the Linux kernel, get the vmlinux + System.map / debuginfo for the matching version

Step 3: Binary diff
  - BinDiff: give it the two IDBs directly, review function-level match results
  - ghidriff: one-line pip install, CLI outputs a markdown report
  - Diaphora: in-IDA plugin, venerable, but requires IDA Pro

Step 4: Locate the changes
  - Filter functions with match score 0.5-0.95 (identical ones are uninteresting;
    completely different ones are usually newly added / renamed)
  - Focus on: newly added ifs / new loop bounds / deleted code blocks
    (what was removed is also a clue)
  - Use an LLM to infer the bug class from before/after pseudocode
    (see references/root-cause-and-poc.md)

Step 5: Write the PoC
  - Integer overflow: construct boundary values (INT_MAX-1, 0xFFFFFFFF)
  - Race: multi-threaded hammering, high-frequency concurrent open/close + ioctl
  - UAF: spray -> free -> reuse pattern
  - OOB: precisely control len / index to step past the boundary
  - Verify the patched version no longer crashes and the unpatched version crashes
    reliably -> bug reproduced
```

### Tool invocation order

```text
Download patch -> unpack -> load into IDA/Ghidra -> BinDiff/ghidriff -> review unmatched/low-match functions
       -> LLM infers bug class -> write PoC -> run on unpatched -> crash -> done
```

## Typical Scenario Examples

### Scenario 1: Windows Patch Tuesday — Kernel CVE reproduction

```text
Background: November 2025 Patch Tuesday, MSRC advisory CVE-2025-62215
      Windows Kernel race condition leading to double free, CVSS 7.0, local privilege escalation
      Microsoft released only the patch — no details, no public PoC

Goal: reproduce the PoC and verify privilege escalation on unpatched Windows 11 22H2 / 23H2

Steps:
1. Search the Microsoft Update Catalog for "2025-11" + KB number, download two builds:
   - 22H2 build 22621.xxxx (unpatched)
   - 22H2 build 22621.yyyy (post-patch)
   Commands:
     expand.exe Windows-KB5052000-x64.msu -F:* C:\out\patched\
     expand.exe C:\out\patched\Windows-KB5052000-x64.cab -F:* C:\out\patched\
   Extract ntoskrnl.exe / win32k.sys / win32kfull.sys / afd.sys

2. Load PDBs for both versions (Microsoft symbol server):
     symchk /v /r ntoskrnl.exe /s SRV*C:\sym*https://msdl.microsoft.com/download/symbols

3. Run BinDiff:
     bindiff old.BinExport new.BinExport
   or ghidriff:
     ghidriff ntoskrnl_old.exe ntoskrnl_new.exe -o diff_out/

4. Review the report, filter functions with similarity 0.6-0.95.
   Suppose an NtXxxIoctl-class function gains a new block:
     KeAcquireSpinLockRaiseToDpc(&obj->Lock);
     if (obj->RefCount == 0) { ... goto cleanup; }
   -> a lock + refcount check was newly added -> race + double free, matching the advisory

5. Write the PoC: user-mode threads simultaneously call NtClose and fire an IOCTL
   against the same object, creating a race window between the close freeing the
   object and the IOCTL still using it.
   Crash lands on the free path after ObfDereferenceObject in ntoskrnl

6. Verify:
   - Run the PoC on unpatched 22621.xxxx: BSOD within ~30 seconds (BAD_POOL_HEADER or DOUBLE_FREE)
   - Run the same PoC on patched 22621.yyyy: no abnormality at all
   -> reproduction successful
```

### Scenario 2: Finding unpatched downstream branches in Linux kernel LTS trees

```text
Background: mainline 6.x fixed an OOB write in a net subsystem
      Ubuntu 22.04 (5.15 LTS) has published a USN with the update
      But some OEM kernels / Azure kernels backport on a slower cadence
      Want to confirm whether lagging branches are still exploitable

Goal: obtain patched/unpatched kernels, diff out the binary change corresponding
      to the fix commit, and rewrite the PoC on the unpatched branch

Steps:
1. Pull the patched and unpatched packages:
     apt download linux-image-5.15.0-101-generic   # patched
     apt download linux-image-5.15.0-100-generic   # unpatched
     dpkg-deb -x linux-image-5.15.0-101-generic_*.deb ./patched/
     dpkg-deb -x linux-image-5.15.0-100-generic_*.deb ./unpatched/
   Extract boot/vmlinuz -> restore the ELF with extract-vmlinux

2. Fetch dbgsym at the same time:
     apt download linux-image-unsigned-5.15.0-101-generic-dbgsym

3. Run ghidriff (Linux-friendly):
     ghidriff vmlinux_5.15.0-100 vmlinux_5.15.0-101 \
              -o /tmp/kdiff/ --max-section-funcs-analyze 8000

4. Search the report for changed functions in net/ipv4/ net/ipv6/ net/sched/ etc.
   Find that the pre-patch version lacked a check of the skb->len upper bound
   before the skb_copy_bits call
   -> OOB read, possibly escalatable to OOB write via a triggerable sysctl

5. On the unpatched downstream branch (e.g., a lagging Azure 5.15.0-1080 backport)
   cross-check: has the fix for the same function been backported?
   If not backported -> the branch is still exploitable -> write the PoC and replay

6. Write the PoC: adapt a syzkaller harness / direct C PoC triggering the relevant syscall
   Verify the branch panics / KASAN reports OOB
```

## Notes

- **Legal boundary** — N-day weaponization must stay within authorized scope (SRC / Bug Bounty / own lab / CTF). Hitting production environments with a 1-day is outright intrusion
- **A patch may only "shrink the blast radius"** — seeing a patch does not mean a complete fix; it may only close one exploitation path while the original bug can still be triggered from another path (killing multiple birds with one stone)
- **Don't be fooled by variable names/types** — Windows patches often include incidental cleanup / renames that look like big changes but are irrelevant. Look at control flow and data flow, not token-level diffs
- **Microsoft patches may add a mitigation rather than a fix** — seeing CFG hardening like `_guard_xfg_dispatch_icall_fptr` does not mean a fix; that is a mitigation
- **Anonymization** — when publishing writeups / PoCs, sanitize target hostnames, internal IPs, and usernames (use `{target_ip}` `{username}` placeholders)
- **Harmless tests must pass on the patched version too** — don't run only on unpatched; otherwise the crash may be environmental rather than the vulnerability
- **Binary diff is not omnipotent** — compiler upgrades / optimization-level changes also drastically alter function layout; first compare N against N-1 (same compiler), never across major versions

---

## On-Demand Bootstrap

### Tool Dependencies

| Tool | Purpose | Auto-installable |
|------|------|-----------|
| BinDiff (Google, 5.x+) | Function-level binary diff, IDA/Ghidra plugin | ✓ (official .deb / .msi available) |
| Diaphora | Veteran IDA diff plugin, requires IDA Pro | ✓ (git clone) |
| ghidriff | Ghidra headless CLI diff, markdown output | ✓ (pip install ghidriff) |
| DeepDiff (commercial) | Next-gen diff tool, higher accuracy | ✗ (commercial license) |
| Ghidra | Runtime base for ghidriff | ✓ |
| IDA Pro | Runtime base for BinDiff / Diaphora | ✗ (commercial) |
| Microsoft Update Catalog | Download MSU/MSP patch packages | Online service |
| wsuspect-proxy | Transparently intercept Windows Update traffic to obtain patches | ✓ (git clone) |
| expand.exe / dism | Unpack MSU / cab | ✓ (built into Windows) |
| rpm2cpio / dpkg-deb | Unpack Linux distribution packages | ✓ |
| symchk | Pull PDBs from the Microsoft symbol server | ✓ (Windows SDK) |

### Bootstrap Command

```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File "&lt;SKILL_ROOT&gt;\skills\scripts\bootstrap-reverse.ps1" -Capability @('bindiff','ghidriff','ghidra','wsuspect-proxy') -StartServices
```

For a detailed tool comparison and commands, see `references/diff-tools-comparison.md`.
For the detailed Patch Tuesday workflow, see `references/patch-tuesday-workflow.md`.
For root-cause inference and PoC templates, see `references/root-cause-and-poc.md`.

---

## Routing Context

**Upstream entries**: `skills/SKILL.md` (master control), `routing.md`

**Upstream skills**:
- `reverse-engineering/` — before diffing, you may need to understand the target binary's overall structure
- `binary-diff/` — if the patched version has no symbols but the pre-patch one does, carry symbols over with binary-diff first

**Downstream skills**:
- `pwn-chain/` — after inferring the bug class, write the full exploit (heap spray, ROP, SMEP/SMAP bypass, privilege-escalation payload)
- `pentest-tools/network-attack-defense/` — weaponize the N-day and deploy it to the target network (package it as a deliverable payload, wire it to C2)
- `attack-chain/` — chain this one N-day into a full attack path (initial access -> privilege escalation -> lateral movement)

**Trigger conditions**: the task contains intent such as "N-day", "patch", "CVE reproduction", "find what a patch fixed", "attack unupdated hosts"

## Task Completion Self-Check (MUST pass before claiming completion)

- [ ] Did I execute every step of the workflow (rather than merely reading it)?
- [ ] Did I use real tool paths based on `tool-index`?
- [ ] Did I produce reproducible evidence (commands/scripts/screenshots/reports)?
- [ ] Did I complete and write back the Checklist items required by RULES?

Files in this skill

  • SKILL.md14.3 KB
  • references/diff-tools-comparison.md9.3 KB
  • references/patch-tuesday-workflow.md9.7 KB
  • references/root-cause-and-poc.md5.7 KB

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.

View all in security →

Comments

Loading comments…

Newsletter

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