mirror of
https://github.com/CyberSecurityUP/NeuroSploit.git
synced 2026-11-25 21:54:26 +01:00
feat(harness): cross-domain attack path chaining engine
Model attack paths by capability exchange instead of CWE identity: each finding declares the artifacts it *provides* and the artifacts it *requires*, and steps link when one produces what the next consumes. New crates/harness/src/attack_path.rs: - 36 artifact types (password hash, Kerberos ticket, machine account / keytab, bearer + cloud token, API key, cert/key, shell, local admin, implant, domain user/admin, cloud role, tenant admin, DB sysadmin, internal reach, source code, sensitive data, agent control, ...). - Reach rules decide what may cross an asset boundary: HostLocal stays on the host, Realm travels inside a domain/tenant (with fuzzy realm matching for CORP\user vs corp.local vs ad:corp), Portable travels anywhere. This is what lets a token lifted from process memory reach a cloud control plane while still refusing bogus host-to-host jumps. - 17 domain planes classified from agent name, CWE, MITRE id, endpoint and evidence text: web, api, network, host, Active Directory, cloud, identity, container, mobile, binary, firmware, AI/LLM, supply chain, wireless, social, physical, OT. - Timeline-aware DAG (observed_at stamped at validation; a later step can never enable an earlier one), typed nodes mirroring the kill chain view (exploited weakness, discovered/compromised credential, accessed resource, loaded implant, established session, impact) and 14 impact terminals up to domain and full tenant compromise. - Path enumeration with budget, prefix and weakness-sequence dedupe, Jaccard diversity filter and impact/severity/pivot scoring. - Renderers: Mermaid, ASCII, JSON, Markdown. Integration: - pipeline: stamps observed_at, persists loot.json (previously the chaining rounds' loot only ever existed inside a prompt), folds loot into the graph and logs the best path. - chain::repair: no longer discards legitimate cross-host links; it consults portable_link instead of requiring a host match. - report: "Attack paths" section in Markdown, HTML and Typst/PDF, plus attack-paths.json and attack-paths.mmd run artifacts (redacted). - CLI: neurosploit paths <run> [--top N] [--mermaid] [--json] [--save]. 15 unit tests cover web, API, mobile, binary, AD, cloud, identity, OT and AI chains, the host-local isolation guard, and the renderers.
This commit is contained in:
1 parent
d3a9726a74
commit
bf2754ece6
9 files changed
+2695
-1
No files matched your search
@@ -186,9 +186,46 @@ Every run is a self-contained folder, `runs/ns-<ts>-<target>/`:
|
||||
| `findings.json` / `findings.md` | validated findings (raw, for tools & re-testing) |
|
||||
| `report.sarif` | SARIF 2.1.0 for CI code-scanning |
|
||||
| `graph/` | attack chains, dependency todolist, Cypher + JSON export |
|
||||
| `attack-paths.json` · `attack-paths.mmd` | cross-domain attack paths (graph + Mermaid timeline) |
|
||||
| `loot.json` | credentials, tokens, hosts and endpoints the chaining rounds carried forward |
|
||||
| `recon.json` · `exploitation.md` · `traces/` | surface, transcript, per-agent traces |
|
||||
| `pocs/` · `evidence/` | runnable PoCs and proof screenshots |
|
||||
|
||||
## Attack paths
|
||||
|
||||
A single weakness is one step. The engagement is the sequence, and the sequence
|
||||
is what produces the impact: a traversal on a hypervisor yields root, root
|
||||
yields a machine-account keytab, the keytab authenticates to the directory, a
|
||||
share holds a database password, the database runs commands, the service
|
||||
account becomes SYSTEM, SYSTEM reads a domain admin hash out of memory, that
|
||||
hash reaches a workstation, and the workstation's process memory holds a cloud
|
||||
token that ends in a tenant administrator.
|
||||
|
||||
NeuroSploit derives that sequence after every agent has reported, across every
|
||||
kind of test it runs — web, API, mobile, binaries, firmware, hosts, internal
|
||||
network, Active Directory, cloud, SaaS identity, containers, CI/CD and supply
|
||||
chain, AI/LLM agents, wireless, OT. Chaining is on what each step **produces**
|
||||
and the next one **consumes** (a hash, a ticket, a token, a shell, an implant,
|
||||
a file, reach into a network), and a link is drawn only where that material
|
||||
could actually travel:
|
||||
|
||||
- **host-local** access (a shell, a writable service, a database role) stays on
|
||||
the host it was obtained on;
|
||||
- **realm-wide** material (domain identities, Kerberos tickets, cloud roles)
|
||||
moves inside its directory or tenant, with realm names matched across their
|
||||
spellings (`CORP\\user`, `corp.local`, `CORP.LOCAL`);
|
||||
- **portable** material (passwords, hashes, API keys, bearer tokens) moves
|
||||
anywhere, because that is what an attacker does with it.
|
||||
|
||||
```bash
|
||||
neurosploit paths <run> # ranked paths, on the run's own timeline
|
||||
neurosploit paths <run> --mermaid # the graph
|
||||
neurosploit paths <run> --json # nodes + edges for your own tooling
|
||||
```
|
||||
|
||||
The same view is written into `report.md`, `report.html` and the PDF, and each
|
||||
finding's `chains_from` is filled with the causes that were derived for it.
|
||||
|
||||
## Integrations
|
||||
|
||||
GitHub / GitLab PR review gate (`neurosploit pr <repo> <n> --fail-on critical`),
|
||||
|
||||
@@ -300,6 +300,25 @@ enum Cmd {
|
||||
/// with local vs chain severity, next moves, a Cypher export — and, with
|
||||
/// --push (or NEO4J_URI set), MERGE into Neo4j and reason over paths
|
||||
/// accumulated across runs
|
||||
/// Cross-domain attack paths for a finished run: the chained story, from
|
||||
/// the first weakness to the compromise it ends in, across web, API,
|
||||
/// mobile, binaries, hosts, Active Directory, cloud and identity.
|
||||
Paths {
|
||||
/// Run id (`ns-…`) or a path to the run directory.
|
||||
run: String,
|
||||
/// How many paths to print.
|
||||
#[arg(long = "top", default_value_t = 3)]
|
||||
top: usize,
|
||||
/// Print the Mermaid graph instead of the terminal view.
|
||||
#[arg(long = "mermaid")]
|
||||
mermaid: bool,
|
||||
/// Print the graph as JSON.
|
||||
#[arg(long = "json")]
|
||||
json: bool,
|
||||
/// Write `attack-paths.json` and `attack-paths.mmd` into the run dir.
|
||||
#[arg(long = "save")]
|
||||
save: bool,
|
||||
},
|
||||
Graph {
|
||||
/// Run id (`ns-…`) or a path to the run directory.
|
||||
run: String,
|
||||
@@ -1005,6 +1024,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
Cmd::Audit { run, anchor } => handle_audit(&base, &run, anchor)?,
|
||||
Cmd::Traffic { run } => handle_traffic(&base, &run)?,
|
||||
Cmd::Sarif { run, out } => handle_sarif(&base, &run, out.as_deref())?,
|
||||
Cmd::Paths { run, top, mermaid, json, save } => handle_paths(&base, &run, top, mermaid, json, save)?,
|
||||
Cmd::Graph { run, internal, push, top } => handle_graph(&base, &run, internal.as_deref(), push, top, cli.neo4j.as_deref()).await?,
|
||||
Cmd::Assurance { run, verify } => handle_assurance(&base, &run, verify)?,
|
||||
Cmd::Compliance { run, framework, include_leads } => handle_compliance(&base, &run, &framework, include_leads)?,
|
||||
@@ -1687,6 +1707,13 @@ pub(crate) fn print_findings(out: &RunOutput) {
|
||||
println!(" severity: {}", chips.join(" "));
|
||||
println!("\n \x1b[1mAttack path / kill chain\x1b[0m");
|
||||
print!("{}", harness::attack_graph::ascii_killchain(&out.findings));
|
||||
// The chained view: what each step handed the next one, across every
|
||||
// plane the run touched. Printed only when something actually chained.
|
||||
let paths = harness::attack_path::build("", &out.findings, &[]);
|
||||
if paths.paths(1).iter().any(|p| p.steps >= 2) {
|
||||
println!("\n \x1b[1mChained attack paths\x1b[0m ({})", harness::attack_path::summary(&paths));
|
||||
print!("{}", paths.ascii(3));
|
||||
}
|
||||
}
|
||||
let toks = token_summary();
|
||||
if !toks.is_empty() {
|
||||
@@ -2004,6 +2031,36 @@ fn handle_traffic(base: &std::path::Path, run: &str) -> anyhow::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// The attack-path view of a finished run.
|
||||
fn handle_paths(base: &std::path::Path, run: &str, top: usize, mermaid: bool, json: bool, save: bool) -> anyhow::Result<()> {
|
||||
let dir = resolve_run(base, run)?;
|
||||
let findings = load_findings(&dir)?;
|
||||
let target = std::fs::read_to_string(dir.join("meta.json"))
|
||||
.ok()
|
||||
.and_then(|t| serde_json::from_str::<serde_json::Value>(&t).ok())
|
||||
.and_then(|v| v.get("target").and_then(|x| x.as_str()).map(String::from))
|
||||
.unwrap_or_else(|| run.to_string());
|
||||
let loot: Vec<String> = std::fs::read_to_string(dir.join("loot.json"))
|
||||
.ok()
|
||||
.and_then(|t| serde_json::from_str(&t).ok())
|
||||
.unwrap_or_default();
|
||||
let g = harness::attack_path::build(&target, &findings, &loot);
|
||||
if json {
|
||||
println!("{}", g.json());
|
||||
} else if mermaid {
|
||||
println!("{}", g.mermaid());
|
||||
} else {
|
||||
println!("target: {target} · {}", harness::attack_path::summary(&g));
|
||||
print!("{}", g.ascii(top));
|
||||
}
|
||||
if save {
|
||||
std::fs::write(dir.join("attack-paths.json"), g.json())?;
|
||||
std::fs::write(dir.join("attack-paths.mmd"), g.mermaid())?;
|
||||
println!("\nwrote {} and {}", dir.join("attack-paths.json").display(), dir.join("attack-paths.mmd").display());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn handle_graph(base: &std::path::Path, run: &str, internal: Option<&str>, push: bool, top: usize, neo4j: Option<&str>) -> anyhow::Result<()> {
|
||||
use harness::graph_memory as gm;
|
||||
let dir = resolve_run(base, run)?;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -306,6 +306,19 @@ pub fn repair(findings: &mut [Finding]) -> usize {
|
||||
.filter(|f| !f.id.is_empty())
|
||||
.map(|f| (f.id.clone(), (f.cwe.clone(), f.endpoint.clone())))
|
||||
.collect();
|
||||
// A cross-host link is wrong for an application-local condition and right
|
||||
// for stolen material: a hash lifted off one host is what authenticates to
|
||||
// the next one, and deleting that edge is what left real engagements
|
||||
// reporting a dozen unconnected hosts. `attack_path` decides which of the
|
||||
// two a given pair is, by asking whether anything the source produced could
|
||||
// have travelled to the destination.
|
||||
let whole: Vec<crate::types::Finding> = findings.to_vec();
|
||||
let by_index: std::collections::HashMap<String, usize> = whole
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, f)| !f.id.is_empty())
|
||||
.map(|(i, f)| (f.id.clone(), i))
|
||||
.collect();
|
||||
let mut removed = 0usize;
|
||||
for f in findings.iter_mut() {
|
||||
let before = f.chains_from.len();
|
||||
@@ -319,7 +332,18 @@ pub fn repair(findings: &mut [Finding]) -> usize {
|
||||
match by_id.get(src) {
|
||||
// An id nobody answers to is a dangling reference, not a chain.
|
||||
None => false,
|
||||
Some((cwe, endpoint)) => cwe_num(cwe) != me_cwe && host_of(endpoint) == me_host,
|
||||
Some((cwe, endpoint)) => {
|
||||
if cwe_num(cwe) == me_cwe {
|
||||
return false;
|
||||
}
|
||||
if host_of(endpoint) == me_host {
|
||||
return true;
|
||||
}
|
||||
match (by_index.get(src), by_index.get(&me_id)) {
|
||||
(Some(&a), Some(&b)) => crate::attack_path::portable_link(&whole[a], &whole[b]),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
f.chains_from.sort();
|
||||
|
||||
@@ -11,6 +11,7 @@ pub mod agents;
|
||||
pub mod assurance;
|
||||
pub mod authz_matrix;
|
||||
pub mod attack_graph;
|
||||
pub mod attack_path;
|
||||
pub mod audit;
|
||||
pub mod belief;
|
||||
pub mod browser;
|
||||
@@ -102,6 +103,7 @@ pub use capability::{Capability, TokenError};
|
||||
pub use browser::{BrowserProbe, BrowserResult};
|
||||
pub use budget::{Budget, Effort, Governor, Mode as BudgetMode, Order as BudgetOrder, Phase as BudgetPhase};
|
||||
pub use chain::{AttackPath, Capability as ChainCapability, Link};
|
||||
pub use attack_path::{Artifact, AttackPathGraph, Domain as AttackDomain, Impact as AttackImpact, NodeKind as PathNodeKind, Path as KillPath};
|
||||
pub use claims::{Claim, ClaimSet, ClaimStatus, Decision, EvidenceLedger};
|
||||
pub use policy::{Act, ActionKind, BlastRadius, EngagementPolicy, Environment, Protocol, Risk, RiskDecision, SafetyPolicy};
|
||||
pub use prosecutor::{ProsecutorVerdict, PROSECUTOR_SYS};
|
||||
|
||||
@@ -3088,6 +3088,18 @@ async fn attack_chain(pool: &ModelPool, cfg: &RunConfig, recon: &str,
|
||||
if !all_new.is_empty() {
|
||||
let _ = tx.send(format!("⛓ attack-chaining added {} finding(s) across pivots", all_new.len())).await;
|
||||
}
|
||||
// Persist the loot. Until now it existed only inside the round prompts and
|
||||
// died with them, so the credentials an operator actually carried forward
|
||||
// never reached the report. The attack-path builder folds this back in as
|
||||
// material nodes.
|
||||
if !loot.is_empty() {
|
||||
if let Some(dir) = cfg.workdir.as_deref() {
|
||||
let _ = std::fs::write(
|
||||
Path::new(dir).join("loot.json"),
|
||||
serde_json::to_string_pretty(&loot).unwrap_or_default(),
|
||||
);
|
||||
}
|
||||
}
|
||||
all_new
|
||||
}
|
||||
|
||||
@@ -3575,6 +3587,22 @@ async fn validate(candidates: Vec<Finding>, pool: &ModelPool, sys: &str, vote_n:
|
||||
}
|
||||
|
||||
async fn validate_with_persist(candidates: Vec<Finding>, pool: &ModelPool, sys: &str, vote_n: usize, tx: &Sender<String>, workdir: Option<&str>) -> Vec<Finding> {
|
||||
// Stamp the clock. A path is a sequence in time as much as in dependency:
|
||||
// the attack-path builder refuses to let a later step enable an earlier
|
||||
// one, and it can only do that if each step records when it was proven.
|
||||
let now = std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.map(|d| d.as_secs())
|
||||
.unwrap_or(0);
|
||||
let candidates: Vec<Finding> = candidates
|
||||
.into_iter()
|
||||
.map(|mut f| {
|
||||
if f.observed_at == 0 {
|
||||
f.observed_at = now;
|
||||
}
|
||||
f
|
||||
})
|
||||
.collect();
|
||||
// Fast-track: findings with no evidence are unverifiable — skip the vote
|
||||
// and flag for human review instead of wasting a validator call that will
|
||||
// always reject ("default to rejected when uncertain" + empty evidence).
|
||||
@@ -4129,6 +4157,30 @@ async fn finish(cfg: RunConfig, _lib: &Library, pool: &ModelPool, recon: String,
|
||||
if chained > 0 {
|
||||
let _ = tx.send(format!("attack paths: {chained} finding(s) linked to what enables them")).await;
|
||||
}
|
||||
// Then chain them ACROSS domains. The rules above are web-local by design
|
||||
// and stop at the host boundary; an engagement's real path does not — it
|
||||
// carries a hash off a hypervisor into a directory, a share password into
|
||||
// a database, a token out of process memory into a cloud tenant. This pass
|
||||
// links on what each step produces and the next one consumes, for every
|
||||
// plane the agent library covers, and only where the material could
|
||||
// actually have travelled that far.
|
||||
{
|
||||
let loot: Vec<String> = cfg
|
||||
.workdir
|
||||
.as_deref()
|
||||
.and_then(|d| std::fs::read_to_string(Path::new(d).join("loot.json")).ok())
|
||||
.and_then(|t| serde_json::from_str(&t).ok())
|
||||
.unwrap_or_default();
|
||||
let crossed = crate::attack_path::apply(&mut findings);
|
||||
let graph = crate::attack_path::build(&cfg.target, &findings, &loot);
|
||||
let best = graph.paths(1);
|
||||
if crossed > 0 || best.first().map(|p| p.steps >= 2).unwrap_or(false) {
|
||||
let _ = tx.send(format!("⛓ attack path: {}", crate::attack_path::summary(&graph))).await;
|
||||
}
|
||||
if let Some(p) = best.first().filter(|p| p.steps >= 2) {
|
||||
let _ = tx.send(format!("⛓ best path: {}", p.narrative)).await;
|
||||
}
|
||||
}
|
||||
// Collect proof screenshots into evidence/<finding-id>-N.png so the report
|
||||
// can embed each image beside its vulnerability.
|
||||
if let Some(dir) = cfg.workdir.as_deref() {
|
||||
|
||||
@@ -128,6 +128,11 @@ pub fn html_with_pocs(target: &str, findings: &[Finding], meta: &EngagementMeta,
|
||||
)
|
||||
};
|
||||
|
||||
// Attack paths: the chained view, ahead of the per-finding detail because
|
||||
// that is the order the question is asked in — what was the route, then
|
||||
// what were the individual holes.
|
||||
let paths_section = attack_paths_html(target, findings);
|
||||
|
||||
let rows: String = sorted
|
||||
.iter()
|
||||
.enumerate()
|
||||
@@ -240,10 +245,12 @@ pub fn html_with_pocs(target: &str, findings: &[Finding], meta: &EngagementMeta,
|
||||
{techrow}{serverrow}\
|
||||
</table>\
|
||||
<h2>Executive Summary</h2><div class=summary-grid>{summary_grid}</div>\
|
||||
{paths_section}\
|
||||
{vuln_summary}\
|
||||
<h2>Findings ({n})</h2>{body}\
|
||||
<p class=footer>Authorized testing only. Confirmed findings passed multi-model voting, receipt grounding and adversarial refute; \"needs-review\" are flagged for a human.<br>NeuroSploit v{VER} · by <b>Joas A Santos</b> & <b>Red Team Leaders</b><br><span style=\"font-family:ui-monospace,monospace\">{provenance}</span></p></body></html>",
|
||||
t = esc(target), n = sorted.len(), body = body, summary_grid = summary_grid, vuln_summary = vuln_summary,
|
||||
paths_section = paths_section,
|
||||
VER = env!("CARGO_PKG_VERSION"),
|
||||
// Which build produced this document. A report that circulates without
|
||||
// it is a report nobody can trace back to the run that made it.
|
||||
@@ -271,6 +278,54 @@ pub fn html_with_pocs(target: &str, findings: &[Finding], meta: &EngagementMeta,
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/// Where the problem is, in one line, as precisely as the finding allows.
|
||||
/// The ranked attack paths as an HTML section. Empty when nothing chained.
|
||||
fn attack_paths_html(target: &str, findings: &[Finding]) -> String {
|
||||
let g = crate::attack_path::build(target, findings, &[]);
|
||||
let paths = g.paths(5);
|
||||
let real: Vec<&crate::attack_path::Path> = paths.iter().filter(|p| p.steps >= 2).collect();
|
||||
if real.is_empty() {
|
||||
return String::new();
|
||||
}
|
||||
let mut s = String::from(
|
||||
"<h2>Attack Paths</h2><p style=\"opacity:.8\">Each path is a proven sequence: a weakness yields \
|
||||
material — a credential, a token, a session, a foothold — and the next step consumes it. Links are \
|
||||
drawn only where that material could travel: host-local access stays on its host, directory and tenant \
|
||||
material moves inside its realm, credentials move anywhere.</p>",
|
||||
);
|
||||
for (i, p) in real.iter().enumerate() {
|
||||
let ends = if p.impacts.is_empty() {
|
||||
"chained impact".to_string()
|
||||
} else {
|
||||
p.impacts.iter().map(|i| i.as_str()).collect::<Vec<_>>().join(" + ")
|
||||
};
|
||||
s.push_str(&format!(
|
||||
"<section class=finding style=border-left-color:#c0392b><h3>Path {} — {}</h3>\
|
||||
<p style=\"opacity:.75\">{} exploited weakness(es) · {} domain(s): {} · {} host(s)</p><ol>",
|
||||
i + 1,
|
||||
esc(&ends),
|
||||
p.steps,
|
||||
p.domains.len(),
|
||||
esc(&p.domains.iter().map(|d| d.as_str()).collect::<Vec<_>>().join(", ")),
|
||||
p.hosts.len().max(1)
|
||||
));
|
||||
for id in &p.nodes {
|
||||
let Some(n) = g.node(id) else { continue };
|
||||
if n.kind == crate::attack_path::NodeKind::Entry {
|
||||
continue;
|
||||
}
|
||||
let detail = if n.detail.is_empty() { String::new() } else { format!(" <span style=\"opacity:.6\">({})</span>", esc(&n.detail)) };
|
||||
s.push_str(&format!(
|
||||
"<li><b>{}</b> — {}{}</li>",
|
||||
esc(n.kind.as_str()),
|
||||
esc(&n.label),
|
||||
detail
|
||||
));
|
||||
}
|
||||
s.push_str("</ol></section>");
|
||||
}
|
||||
s
|
||||
}
|
||||
|
||||
pub fn location_line(f: &Finding) -> String {
|
||||
match (f.location.trim(), f.endpoint.trim()) {
|
||||
("", "") => "(location not recorded)".into(),
|
||||
@@ -549,6 +604,45 @@ pub fn typst_report(target: &str, findings: &[Finding], dir: &Path) -> std::io::
|
||||
accounts_arr,
|
||||
tq(&crate::provenance::Provenance::process().tag()),
|
||||
));
|
||||
// Attack paths for the PDF: the chained story, as data the template
|
||||
// renders. A client deliverable that lists holes without the route between
|
||||
// them makes the reader rebuild the engagement in their head.
|
||||
{
|
||||
let g = crate::attack_path::build(target, findings, &[]);
|
||||
let paths = g.paths(5);
|
||||
data.push_str("#let attack_paths = (\n");
|
||||
for p in paths.iter().filter(|p| p.steps >= 2) {
|
||||
let ends = if p.impacts.is_empty() {
|
||||
"chained impact".to_string()
|
||||
} else {
|
||||
p.impacts.iter().map(|i| i.as_str()).collect::<Vec<_>>().join(" + ")
|
||||
};
|
||||
let meta_line = format!(
|
||||
"{} exploited weakness(es) · {} domain(s): {} · {} host(s)",
|
||||
p.steps,
|
||||
p.domains.len(),
|
||||
p.domains.iter().map(|d| d.as_str()).collect::<Vec<_>>().join(", "),
|
||||
p.hosts.len().max(1)
|
||||
);
|
||||
let steps: String = p
|
||||
.nodes
|
||||
.iter()
|
||||
.filter_map(|id| g.node(id))
|
||||
.filter(|n| n.kind != crate::attack_path::NodeKind::Entry)
|
||||
.map(|n| {
|
||||
let detail = if n.detail.is_empty() { String::new() } else { format!(" ({})", n.detail) };
|
||||
format!("{},", tq(&format!("{} — {}{}", n.kind.as_str(), n.label, detail)))
|
||||
})
|
||||
.collect();
|
||||
data.push_str(&format!(
|
||||
" (title: {}, meta: {}, steps: ({})),\n",
|
||||
tq(&ends),
|
||||
tq(&meta_line),
|
||||
steps
|
||||
));
|
||||
}
|
||||
data.push_str(")\n");
|
||||
}
|
||||
data.push_str("#let findings = (\n");
|
||||
for f in &sorted {
|
||||
let owasp = if f.owasp.is_empty() { f.cwe.clone() } else { f.owasp.clone() };
|
||||
@@ -694,6 +788,18 @@ pub fn markdown(target: &str, findings: &[Finding], meta: &EngagementMeta) -> St
|
||||
out.push_str("## Executive summary\n\n");
|
||||
out.push_str(&exec_summary(target, meta, &confirmed, &review));
|
||||
|
||||
// --- Attack paths ---
|
||||
// An engagement is read as a story before it is read as a list: what did
|
||||
// one weakness hand the attacker, and what did the next one do with it.
|
||||
// The section is placed before the per-finding detail because that is the
|
||||
// order the question is asked in.
|
||||
{
|
||||
let paths = crate::attack_path::build(target, findings, &[]);
|
||||
if paths.paths(1).iter().any(|p| p.steps >= 2) {
|
||||
out.push_str(&paths.markdown(5));
|
||||
}
|
||||
}
|
||||
|
||||
// --- Vulnerability table ---
|
||||
out.push_str("## Vulnerability summary\n\n");
|
||||
if confirmed.is_empty() && review.is_empty() {
|
||||
@@ -855,6 +961,18 @@ pub fn write_all(target: &str, findings: &[Finding], dir: &Path) -> std::io::Res
|
||||
if let Err(e) = crate::graph_memory::write_artifacts(target, &run_id, raw, dir) {
|
||||
eprintln!("graph: skipped ({e})");
|
||||
}
|
||||
// Cross-domain attack paths: the chained view, as JSON for tooling and
|
||||
// Mermaid for anything that renders a diagram. Loot carried forward by the
|
||||
// chaining rounds is folded in when the run recorded it.
|
||||
{
|
||||
let loot: Vec<String> = std::fs::read_to_string(dir.join("loot.json"))
|
||||
.ok()
|
||||
.and_then(|t| serde_json::from_str(&t).ok())
|
||||
.unwrap_or_default();
|
||||
let g = crate::attack_path::build(target, raw, &loot);
|
||||
let _ = std::fs::write(dir.join("attack-paths.json"), redactor.text(&g.json()));
|
||||
let _ = std::fs::write(dir.join("attack-paths.mmd"), redactor.text(&g.mermaid()));
|
||||
}
|
||||
let pocs: Vec<String> = std::fs::read_dir(dir.join("pocs"))
|
||||
.map(|rd| rd.filter_map(|e| e.ok()).map(|e| e.file_name().to_string_lossy().to_string()).collect())
|
||||
.unwrap_or_default();
|
||||
@@ -883,6 +1001,8 @@ pub fn rebuild(dir: &Path) -> std::io::Result<PathBuf> {
|
||||
crate::attack_graph::remap_stages(&mut findings);
|
||||
crate::chain::repair(&mut findings);
|
||||
crate::chain::apply_links(&mut findings);
|
||||
// The cross-domain links the web-local rules cannot see.
|
||||
crate::attack_path::apply(&mut findings);
|
||||
let _ = std::fs::write(dir.join("findings.json"), serde_json::to_string_pretty(&findings).unwrap_or_default());
|
||||
let status: serde_json::Value = std::fs::read_to_string(dir.join("status.json"))
|
||||
.ok()
|
||||
|
||||
@@ -92,6 +92,13 @@ pub struct Finding {
|
||||
/// the outcome in code instead of a judge reading prose.
|
||||
#[serde(default)]
|
||||
pub claims: Option<crate::claims::ClaimSet>,
|
||||
/// When this step was proven, as epoch seconds. An attack path is a
|
||||
/// sequence in time as much as in dependency: two findings that chain are
|
||||
/// ordered by when each was demonstrated, and a report that draws the
|
||||
/// path without the clock cannot say which step opened the next one.
|
||||
/// Zero means unknown, and the path falls back to dependency order.
|
||||
#[serde(default)]
|
||||
pub observed_at: u64,
|
||||
/// Structured artifacts for the deterministic validation engine: the
|
||||
/// baseline/attack pair, repeats, markers, identity pair. Agents that
|
||||
/// follow the evidence contract emit this alongside the finding, and
|
||||
@@ -133,6 +140,7 @@ impl Default for Finding {
|
||||
repro_steps: Vec::new(),
|
||||
claims: None,
|
||||
evidence_data: None,
|
||||
observed_at: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +116,28 @@
|
||||
|
||||
#let sorted = findings.sorted(key: f => sevrank(f.severity))
|
||||
|
||||
// ---- Attack paths ----
|
||||
// The chained view: what one weakness handed the next, across every plane the
|
||||
// engagement touched. Rendered before the per-finding detail because that is
|
||||
// the order the question is asked in.
|
||||
#let paths = if type(attack_paths) == array { attack_paths } else { () }
|
||||
#if paths.len() > 0 [
|
||||
#v(8pt)
|
||||
== Attack Paths
|
||||
#v(2pt)
|
||||
#text(9pt, fill: gray)[Each path is a proven sequence: a weakness yields material — a credential, a token, a session, a foothold — and the next step consumes it. A link is drawn only where that material could travel: host-local access stays on its host, directory and tenant material moves inside its realm, credentials move anywhere.]
|
||||
#for (i, p) in paths.enumerate() [
|
||||
#v(6pt)
|
||||
#block(width: 100%, inset: 8pt, radius: 6pt, fill: rgb("#faf3f2"), stroke: 0.5pt + rgb("#c0392b"))[
|
||||
#text(10pt, weight: "bold")[Path #str(i + 1) — #p.title]
|
||||
#v(-2pt)
|
||||
#text(8pt, fill: gray)[#p.meta]
|
||||
#v(2pt)
|
||||
#enum(..p.steps.map(s => [#text(9pt)[#s]]))
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
// ---- Vulnerability summary table ----
|
||||
#if sorted.len() > 0 [
|
||||
#v(8pt)
|
||||
|
||||
Reference in new issue
Block a user