Purpose
mg-exploitgen generates a CVE-driven exploit project scaffold. Given a CVE
identifier, an operator-supplied CVE description, and a target-environment JSON,
it lays down a Rust project skeleton ready to be instrumented and tested in a lab.
Inputs
<cve>— CVE identifier (case-insensitive; normalized to upper case; rejected if it contains anything outside[A-Za-z0-9-]).--cve-description <path>— Markdown or text file with the CVE description. Not fetched from the network; the operator pastes it.--target-env <path>— JSON describing the target stack, mitigations, reachability, and constraints.
Output
engagements/<name>/exploits/<CVE-ID>/
|-- Cargo.toml
|-- runbook.md
|-- src/
| |-- main.rs # thin orchestrator
| |-- scanner.rs # version detection
| |-- validator.rs # precondition check that doesn't fire payload
| |-- payload.rs # primitive stub + scope/legality comments
| `-- cleanup.rs # revert artifacts the exploit leaves
`-- tests/
`-- smoke.rs # scaffold compile-only test
Every generated runbook.md opens with:
Authorized testing only. Confirm scope before running.
The generated Cargo.toml uses a deterministic crate name derived from
the CVE id: CVE-2026-1234 → exploit_cve_2026_1234.
CLI
mg-exploitgen scaffold acme-bounty CVE-2026-0001 \
--cve-description /tmp/cve-2026-0001.md \
--target-env /tmp/target-env.json
# Offline mode — deterministic placeholders, no LLM call
mg-exploitgen scaffold acme-bounty CVE-2026-0001 \
--cve-description /tmp/cve-2026-0001.md \
--target-env /tmp/target-env.json \
--offline --force
How it works
- Directory tree and Cargo skeleton come from static templates embedded via
include_str!. The LLM never picks file names or controls directory structure. - The model only fills guidance fields that get pasted into file-header
comments and into a numbered runbook step list:
scanner_strategy,validator_strategy,payload_strategy,cleanup_strategytarget_env_summary,cve_summaryrunbook_steps,notes
- The model returns one JSON object. The harness’s
extract_first_json_objectparser tolerates assistant chatter around the JSON block. - CVE description and target-env JSON are wrapped as untrusted
<cve_description>/<target_env>evidence in the prompt.
Safety
- No network access. CVE descriptions are operator-supplied paste-only.
- Generated scaffold compiles cleanly under
cargo check(verified with a smoke run during S4). The stage stubs deliberately do nothing until the operator implements them. - The “Authorized testing only” banner is hard-coded in the runbook template; you cannot generate a runbook without it.
Harness
mg-harness exposes exploit.scaffold (ReadOnly — no
traffic leaves the box).