P7 โ€” AutoPatch (Autonomous CVE Remediation)


What It Does

Reads vulnerability findings from DefectDojo, snapshots the target host with ZFS, applies patches via apt/apk, restarts affected services, verifies with Trivy, and auto-rolls back on failure. The weakest point in most SMB security pipelines is patch Tuesday โ€” this closes it with zero cloud dependency.

Pipeline

DefectDojo API  โ†’  classify by CVSS + KEV + EPSS
          โ†“
   ZFS snapshot   (pre-patch rollback point)
          โ†“
   apt / apk      (dry-run โ†’ real)
          โ†“
   systemctl      (restart affected services)
          โ†“
   Trivy          (verify fix landed; new findings = regression)
          โ†“
   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
   SUCCESS         FAILURE
     โ†“               โ†“
   log + alert    ZFS rollback + alert

Design Decisions

  • ZFS not LVM โ€” ZFS snapshots are atomic, instant, and have cheap rollback. LVM snapshots degrade on write.
  • DefectDojo as truth source โ€” single UI for vulnerability triage across all homelab assets.
  • Trivy for verify โ€” same scanner, pre + post, so the comparison is apples-to-apples.
  • Auto-rollback threshold โ€” any new critical finding or any service that fails to restart = immediate rollback.

Engineering Details

  • 40 tests covering pipeline stages, rollback paths, systemctl failure modes, Trivy diff parsing, DefectDojo API error handling.
  • Zero cloud deps โ€” all state local (SQLite job queue, filesystem logs, ZFS snapshots).
  • Dry-run first โ€” every pipeline starts with apt-get -s install (simulate) before the real patch.
  • systemd user service โ€” runs under non-root user with carefully scoped sudo rules.

Stack

Python 3.11+ ยท DefectDojo REST API ยท ZFS ยท apt / apk ยท systemctl ยท Trivy ยท SQLite job queue ยท pytest.

Why This Was Built

Patch Tuesday is a human-time sink. If an LLM-driven CVE triage can rank findings and a trusted script can apply fixes with safe rollback, patching stops being the weakest link. P7 is the operational side of the AIxCC thesis: not just finding vulnerabilities (P4 Mini-CRS does that) but closing them repeatably.

โ† back