Field manual · 07

Exploitation and attack paths

Gated categories, the identity and access matrix, out-of-band canaries, retests, verifiers, and the discipline of claiming only what the evidence proves.

The exploitation class, and how it is gated

Exploitation is not a phase; it is a category attached to an action. Every pentest_exec call carries one, and the effective category is the more severe of the catalogue entry and the one you request — a caller may raise it, never lower it, so nmap cannot be relabelled recon while it exploits something.

In DEFAULT the gated categories run directly. In SAFE all six block until the operator decides: exploitation, privesc, lateral, exfiltration, credential and credential_dump. The request is created only after the scope check, so an out-of-scope command never reaches the queue. The card records tool, command, target, phase, worker, rationale and impact; the operator approves once, approves for the phase, or denies. No answer expires after approvalTimeoutMs (300000 ms by default) — a denial, not an approval.

CategoryTypical sourceSAFERecord needs
exploitationCatalogue (sqlmap, metasploit-framework)ApprovalCommand, exit code, excerpt, evidence id
privescRequested on an ordinary binaryApprovalPre/post identity output, escalation command
lateralRequested (chisel, ligolo-ng)ApprovalSource, destination, port, proof

A refusal is a result, not an invitation: the audit records scope_denied or the denial, and retry loops are forbidden. The way forward is an operator scope change, a discovery expansion through pentest_scope when the host is inside an authorized root, or a less intrusive check.

Approval dialog for a metasploit command showing target, scope status, phase, worker, rationale and expected impact
Figure 7.1 — The approval card: tool, command, target, scope verdict, phase, worker, rationale, impact, decisions.

The bounded exploitation loop

An exploit attempt is not one command. pentest_exploitation turns it into a deterministic loop: identify a candidate, capture the baseline, run one least-impact attempt, classify the real output, compare, change exactly one variable, then retry, pivot, derive a minimal custom proof or confirm. Actions are plan, status, record and delegate.

plan requires the exploitation phase, an active scope and an accepted RoE, and materialises the round descriptors with a per-round focus and evidence list. Candidates can come from searchsploit/Exploit-DB, CVE/NVD, a Metasploit module, a Nuclei template, an NSE script, sqlmap, hydra, smbclient, impacket or a manual proof; destructive candidates and non-HTTP references are rejected. Caps are enforced, not advisory:

LimitDefaultHard maximum
Rounds612
Attempts per candidate35
Candidates—20
Excerpt / delegation prompt600 characters600 characters / 20 KB

record accepts only a real observation from pentest_exec: exit code, stdout/stderr, timeout and status, plus explicit denied, out-of-scope, unstable, detected, missing-tool or success flags. It classifies the outcome and returns the next action. A denial, an approval that is still pending, an out-of-scope result, a timeout, an unstable target or a detection signal stops the loop — none of them is retried around. Exactly one variable changes per retry, and the same failed command is never re-run.

pentest_exploitation({ action: "plan", target: "shop.example.com",
  service: "http", version: "nginx 1.24", maxRounds: 6 })

pentest_exploitation({ action: "record", round: 1, tool: "nuclei",
  outcome: "partial", exitCode: 0, stdout: "CVE-2025-12345 detected" })

Every round has to be reproducible: exact argv, tool, round number, real exit code, duration, redacted excerpt, the classification and its signals, baseline-versus-attempt comparison and an evidence id linked to the finding. A confirmation is a second run with the same least-impact proof and a second evidence id; success is never promoted to exploited from one attempt. delegate prepares the exploit-researcher, exploit-operator and independent exploit-verifier roles with their write scopes and task dependencies, using the same Team/planner machinery rather than a parallel framework.

Full reference: docs/EXPLOITATION.md.

The identity and access matrix

An exploitation result is stronger when you can say who could do it. pentest_identity keeps an account inventory and an account × asset matrix, with actions add, remove, list, matrix, gaps and recordTest. Accounts are deduplicated by label plus role and carry auth (password, sso, token, key, none), mfa, tags, privileges and access entries {asset, level, evidenceId}.

Limits are 200 accounts, 50 access entries each and 500 test records. Secrets never enter state: only whitelisted fields are stored, and free text masks password=… fragments.

{ "action": "recordTest",
  "accountId": "acct_2",
  "asset": "http://192.168.100.101:8081/ping",
  "result": "pass",
  "method": "cookie replay; 200 + uid",
  "evidenceId": "ev_mwyzg3ir_zfjgnv51rv" }

matrix builds columns from access entries, an explicit assets array, finding assets and asset nodes, then summarises accounts, assets, tested coverage, MFA and admin grants. gaps derives deterministic findings:

Gap typeSeverityCondition
no-mfahigh for admin accounts, otherwise mediumNo MFA flag
admin-without-needhighAdmin access without an admin role or privilege
account-without-accesslowNo access entry above none
untested-assetinfoAsset column with no identity test record

Record only tests you performed, with result pass, fail, partial or blocked, plus the evidence; a matrix of guesses reads as coverage you do not have.

Out-of-band canaries

Blind SSRF, XXE and asynchronous callbacks need a target that calls you. pentest_oob manages local canaries: create returns an unguessable rt-… token and its URL under /dsh-redteam/canary/<token>; check, list, hit, close and prune inspect and retire them. TTL is 1–1440 minutes (default 60); up to 200 canaries, 100 hits each and 5000 hits per engagement are kept.

A closed canary rejects hits; an expired one still keeps a late trigger. A supplied target must be in scope. The Host route answers GET and POST, caps the body at 4 KiB, allows 60 requests per minute per token and returns a 1×1 PNG — never JSON or an error page that tells the target what it found.

The token is a bearer capability: anyone holding the URL can write hits, so a live token has no place in a report or chat. Hits store method, path, source IP and user agent with the token redacted.

What a callback proves

A hit proves that a request reached your Host route from somewhere, with some method and path — reachability and, for SSRF, that the server can be made to issue a request. It does not prove code execution, data access or impact. Pair it with a verifier or a second observation before raising a finding's status.

Retests: plan first, replay second

pentest_retest has two actions. plan is offline and read-only: it parses the stored HTTP evidence — a raw request block or a curl command — into a replay plan. run performs one scoped replay and requires confirm: true, a deliberate act after reading that plan.

Only GET, HEAD and POST are planned. Anything else is refused, as are non-HTTP(S) targets, multipart uploads, data from a file, and destructive-looking paths or actions (delete, purge, revoke, shutdown). POST is medium risk; the other two are low.

Evaluation prefers the strongest oracle. Markers beat status, status beats the baseline body hash. A marker present means still vulnerable, absent means fixed — unless the body was empty or the status 5xx, which is inconclusive. Mapping: fixed → closed, still-vulnerable → open, inconclusive → unverified.

{ "action": "plan",
  "findingId": "nd_mwyze8zm0faaxk" }

{ "action": "run",
  "findingId": "nd_mwyze8zm0faaxk",
  "confirm": true }

The run writes a retest record, captures it as JSON evidence linked to the finding, stores the verdict at meta.retest and audits finding_retested. It never promotes a finding to exploited and never rewrites the original evidence: a retest is a new observation, not a correction of the past.

Verifiers: confirmed, refuted, inconclusive

pentest_verify is deterministic and evidence-only: it inspects vault records, tool runs, responses and the finding text, and returns a verdict with checks, missing signals and confidence. It sends no request and calls no model. Ten CWE rules ship today — 78, 79, 89, 22, 352, 319, 693, 200, 918, 601 — from command injection to open redirect; an unrecognised CWE yields inconclusive with a check that says why.

Each rule needs an attack signal from the request or finding and a confirmation signal from captured output — which is why a 200 status alone confirms nothing. apply: true promotes unverified to verified only on confirmed; it can never set exploited. A confirmed verdict also creates a fact node linked by a proves edge. Refuted and inconclusive results stay in a bounded validation history (five entries).

Narrating the attack path

The graph is Goal → Intent → Fact → Finding → Asset, with labelled edges (spawns, yields, derived_from, proves, parent). The dashboard renders the recorded chain as an ordered attack path — up to eight steps, each linking to its finding card. Nodes and edges, not a story from memory.

Flow tab showing goal, intent, facts and findings arranged left to right with confidence percentages
Figure 7.2 — The Flow tab is the graph the report renders. A finding without a fact parent is a claim without a chain.

Use identifiers that exist: finding ids, evidence ids, tool run ids, phase names. Say which artefact proves which link, and mark inference as inference — or leave it out. The timeline narrative is an internal section (includeInternal) and never reaches a client copy by accident.

Never claim more than the evidence shows

The store enforces part of this: a finding requested as verified or exploited without evidence text, a tool run id, linked evidence ids or a validation record is stored unverified, and the result says so. The rest is judgement: verified means the evidence reproduces the weakness; exploited claims impact.

The sample set is the model

The published lab engagement ended with three verified findings, a root shell and a pivot flag, and the report still states: 3 findings were recorded, of which 0 include exploitation evidence. Nothing was promoted for effect. That sentence is what an honest report looks like.

Worked example: command injection → post-exploitation → retest

Engagement RT-20261127-F11C, lab target http://192.168.100.101:8081/, DEFAULT mode: nine phases, ten evidence records, three findings.

Attack path from command injection to privilege escalation to pivot, with the evidence record that proves each hop 1 · Command injection /ping?host= · CWE-78 · 9.8 uid=1000(support) 2 · Privilege escalation sudo NOPASSWD find · CWE-250 uid=0(root) 3 · Lateral movement pivot to internal:8080 CWE-441 · 4.9 · flag ev_mwyzdidl_3sfs8voo83 curl output, exit 0 ev_mwyzewt4_eesba50qgr sudo -n -l output ev_mwyzfoww_tmhv9hae4u internal flag, exit 0 Each hop has its own finding, evidence id and tool run — a chain, not one large claim.
Figure 7.3 — Three hops, three findings, three evidence ids — exactly the report's attack path.

Injection was proven with curl --get --data-urlencode host=127.0.0.1;id;hostname: exit 0, uid=1000(support) (ev_mwyzdidl_3sfs8voo83). Escalation was proven twice — sudo -n -l showing NOPASSWD: /usr/bin/find (ev_mwyzewt4_eesba50qgr), then the -exec /bin/sh escape returning uid=0(root) (ev_mwyzfcho_mwoo5m09lq). The pivot reached internal:8080 from the entry host (ev_mwyzfoww_tmhv9hae4u).

Now the retest: a plan against the first finding replays a GET carrying the marker uid=1000(support). If it reappears the verdict is still-vulnerable (record: open); a validated parameter answering 400 gives fixed (record: closed); an empty body or 5xx gives inconclusive. The retest adds a dated observation beside the original proof and never turns the finding into exploited.

Deep reference: documentation, tool reference, wiki, sample artefacts, resources.

What good looks like

  • Every gated action in SAFE has an operator decision behind it, named in the audit trail.
  • The identity matrix holds only access levels you tested, each with an evidence id and a recordTest result.
  • OOB tokens are short-lived, closed when done, never pasted into a deliverable.
  • Retests are planned, reviewed and confirmed explicitly — GET, HEAD or POST only — as a new lifecycle row.
  • verified requires a reproduction; exploited requires impact you demonstrated. Everything else stays unverified, in the report and in the graph.