diff --git a/neurosploit-rs/crates/harness/src/validation.rs b/neurosploit-rs/crates/harness/src/validation.rs index fc6a188..8666b80 100644 --- a/neurosploit-rs/crates/harness/src/validation.rs +++ b/neurosploit-rs/crates/harness/src/validation.rs @@ -1358,6 +1358,21 @@ fn wire_temper(v: Verdict, ev: Option<&Evidence>) -> Verdict { } fn judge_evidence(f: &Finding, ev: Option<&Evidence>) -> Verdict { + // An edge/WAF response is not a test of the application. This catches the + // common false positive where `/admin` returns a 200 Cloudflare block page + // and gets reported as an exposed admin panel. + if let Some(ev) = ev { + if let Some(a) = &ev.attack { + let w = crate::waf::classify_exchange(a); + if !w.origin.supports_a_finding() { + return Verdict::Rejected(format!( + "the attack response came from the {} ({}), not the application — the app was never tested", + w.origin.as_str(), + w.reason + )); + } + } + } // Authorization-matrix evidence is self-identifying: if the matrix engine // (or an agent) recorded per-identity probes or the 403-vs-business-error // oracle, judge it with the function-level rule regardless of how the diff --git a/neurosploit-rs/crates/harness/src/waf.rs b/neurosploit-rs/crates/harness/src/waf.rs index de4f54e..e6c5eda 100644 --- a/neurosploit-rs/crates/harness/src/waf.rs +++ b/neurosploit-rs/crates/harness/src/waf.rs @@ -179,13 +179,25 @@ pub fn classify(status: u16, headers: &[(String, String)], body: &str) -> Verdic "forbidden by rule", "error 1020", "reference #", + "sorry, you have been blocked", + "you have been blocked", + "cloudflare ray id", + "unable to access", ]; let says_blocked = block_phrases.iter().any(|p| body_low.contains(p)); // A proxy signature alone is NOT a block. What makes a response the edge's // rather than the application's is an enforcement marker, or block-page // wording on a status that fits — never the mere presence of a CDN. - let blocked_status = matches!(status, 403 | 406 | 419); + // + // Cloudflare and some WAFs also serve the block page with HTTP 200. A 200 + // is only a block on wording that cannot be an ordinary app page (the + // "Sorry, you have been blocked" page and its Ray ID), never on a generic + // "access denied" a normal response might contain. + let strong_block = body_low.contains("sorry, you have been blocked") + || body_low.contains("cloudflare ray id") + || body_low.contains("attention required! | cloudflare"); + let blocked_status = matches!(status, 403 | 406 | 419) || (status == 200 && strong_block); if enforced || (says_blocked && blocked_status) { let reason = match &vendor { Some(v) if enforced => format!( @@ -471,6 +483,17 @@ mod tests { assert!(i.note.contains("Cloudflare")); } + #[test] + fn a_200_block_page_is_still_the_edge() { + let v = classify( + 200, + &h(&[("cf-ray", "a63e9ead3acfc194"), ("server", "cloudflare")]), + "

Sorry, you have been blocked

Cloudflare Ray ID: a63e9ead3acfc194

", + ); + assert_eq!(v.origin, Origin::EdgeBlocked); + assert!(!v.origin.supports_a_finding()); + } + #[test] fn a_block_page_echoing_the_payload_is_not_reflection() { // The classic false positive: the CDN's block page quotes the payload