diff --git a/control-map/data/cra_control_map.json b/control-map/data/cra_control_map.json index 0513e4c..a8186b5 100644 --- a/control-map/data/cra_control_map.json +++ b/control-map/data/cra_control_map.json @@ -137,6 +137,18 @@ "yocto-local-conf-no-security-flags" ], "check": "The image's shipped configuration must be secure by default: an sshd_config that permits root or password logins, or a distro built without security_flags.inc (stack protector, FORTIFY_SOURCE, PIE, RELRO), violates it." + }, + { + "tool": "dast", + "scan_type": "dast", + "languages": [], + "cwe": [ + "CWE-16", + "CWE-693" + ], + "rules": [], + "check": "The running application leaves a browser protection off by default: a missing or weak Content-Security-Policy or another missing security header on what it serves.", + "attach_only": true } ], "note": null, diff --git a/control-map/src/lib.rs b/control-map/src/lib.rs index cb25df3..319733c 100644 --- a/control-map/src/lib.rs +++ b/control-map/src/lib.rs @@ -231,6 +231,29 @@ mod tests { assert!(map.controls_for_cwe("CWE-0").is_empty()); } + #[test] + fn a_missing_content_security_policy_is_evidence_for_secure_defaults() { + // DAST reports a missing CSP as CWE-16 and a missing protection + // mechanism as CWE-693 (#998). Neither makes the control count as + // checked: the DAST checks look at what one URL serves. + let map = ControlMap::cra().expect("map"); + for cwe in ["CWE-16", "CWE-693"] { + let ids: Vec<&str> = map + .controls_for_cwe(cwe) + .iter() + .map(|c| c.control.as_str()) + .collect(); + assert_eq!(ids, ["cra-ai-1"], "{cwe}"); + } + let dast = map + .coverage("cra-ai-1") + .and_then(|c| c.scans.iter().find(|s| s.tool == "dast")) + .expect("a dast binding"); + assert!(dast.attach_only); + // So the CRA status never reads "checked" because of it. + assert!(!dast.applies_to(&["python".to_string()])); + } + #[test] fn cra_map_loads_all_40_controls() { let map = ControlMap::cra().expect("CRA map should parse"); @@ -306,14 +329,15 @@ mod tests { #[test] fn every_code_binding_names_its_languages() { - // Only tools that do not read source code may be language-independent; - // a rule binding without languages would claim every language. + // Only tools that do not read source code may be language-independent + // (DAST tests the running application); a rule binding without + // languages would claim every language. let map = ControlMap::cra().expect("map"); for control in &map.controls { for scan in &control.scans { let reads_code = !matches!( scan.tool.as_str(), - "gitleaks" | "secret-files" | "syft" | "osv" | "binary-inventory" + "gitleaks" | "secret-files" | "syft" | "osv" | "binary-inventory" | "dast" ); assert_eq!( reads_code, diff --git a/docs/features/control-mapping.md b/docs/features/control-mapping.md index 23af982..e61021f 100644 --- a/docs/features/control-mapping.md +++ b/docs/features/control-mapping.md @@ -36,6 +36,7 @@ For the **CRA** framework (40 controls) the split is **21 covered · 0 needs_too - **mobsfscan** for Android and iOS apps, bound **by CWE** (a mobsfscan binding only ever attaches mobsfscan findings): `cra-ai-1` (debuggable, exported components, outdated `minSdkVersion`), `7`, `8`, `9`, `13`, `14`, `15` (cleartext, TLS, App Transport Security), `16` and `20`. Each binding lists only the languages mobsfscan has rules for under those CWEs, so `cra-ai-1` covers Java and Kotlin (its manifest checks) but not Swift. - **DevSkim** for C# and VB.NET (#494), bound **by CWE** (each DevSkim rule gets its CWE in `pipeline/devskim.rs`; its SARIF carries none): `cra-ai-1` (tracing), `8`, `10` (cookies without Secure), `13`, `14` (DPAPI without entropy), `15`, `16` and `20` (deserialisation, XXE). - **Yocto recipe lint** (oelint-adv and our `yocto-config` rules), bound **by rule id** with the language `bitbake`: `cra-ai-1` (debug and root-login image features, sshd root/password logins, a distro without `security_flags.inc`), `cra-ai-8` (empty-password image features, passwords in `EXTRA_USERS_PARAMS`) `cra-ai-6` (downloads without a checksum, `AUTOREV`, git tags) and `cra-ai-2` (network access in tasks, `http://` fetches). `cra-ai-2` stays not code-checkable; these are its only bindings, so the CRA status assesses it only where the scanned languages include `bitbake` (a Yocto layer tree), and shows it as not code-checkable everywhere else. +- **DAST** (#998), bound **by CWE** and `attach_only`: `cra-ai-1` for a missing or weak Content-Security-Policy (CWE-16) and a missing protection mechanism (CWE-693) on what the running application serves. The DAST checks look at one URL, so the binding attaches these findings to the control but never makes it count as checked. DAST findings with other CWEs get the controls any binding lists for their CWE. - **8 grounded surface checks** (`cra-ai-6`, `11`, `12`, `24`, `27`, `28`, `29`, `30`): the absence-based controls (no rate limiting, no security logging, no update-signature check…) that have no syntactic pattern. - **Marked not_code_checkable** (`cra-ai-2`, `3`, `4`, `5`, among the 19): minimal attack surface, secure architecture, least privilege, tamper protection. A not-code-checkable control with a binding that applies to the scanned languages is assessed like a covered one there; today that is only `cra-ai-2` on Yocto layer trees.