From ab0c3350dda76c687c3c3f9f1f68ecd2a88a7893 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Date: Tue, 6 Oct 2026 17:58:42 +0200 Subject: [PATCH] feat(csaf): read vendor CSAF advisories for matching (#515, part A) - compliance_core::csaf_ingest: a CSAF 2.0 advisory read into what matching needs. Products from the product tree (vendor, family, name inherited by each product_version / product_version_range branch), full_product_names and relationships, with their exact version or vers range, CPE, purl and order numbers (Siemens model_numbers, skus). Per vulnerability: CVE, title, description, highest CVSS score and severity, affected / fixed / not affected / under investigation / recommended products (all eight product_status keys) and the remediations. The advisory's readable page (a self reference that is not the JSON or PDF), the link Siemens' terms ask for; TLP label. AdvisoryProduct::covers(name, version) and Advisory::fixed_versions for matching. - compliance_core::version: cmp_dotted moves here from nvd_cpe.rs (shared), and a vers range parser per the purl spec (=, !=, <, <=, >, >=, *, |-joined intervals; generic/intdot/semver/all compared as dotted versions). - Fixtures: CISA ICSA-26-260-07 (public), Siemens SSA-240718 (terms allow redistribution with the link, in the README), a synthetic VDE-shaped advisory; an #[ignore] test reads the newest live advisory of CODESYS (CERT@VDE), Siemens and CISA. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p --- compliance-agent/src/pipeline/nvd_cpe.rs | 32 +- compliance-core/src/csaf_ingest.rs | 411 +++++++++++++++++ compliance-core/src/lib.rs | 2 + compliance-core/src/version.rs | 215 +++++++++ compliance-core/tests/csaf_ingest.rs | 148 +++++++ compliance-core/tests/fixtures/csaf/README.md | 9 + .../tests/fixtures/csaf/icsa-26-260-07.json | 417 ++++++++++++++++++ .../tests/fixtures/csaf/ssa-240718.json | 162 +++++++ .../tests/fixtures/csaf/vde-synthetic.json | 78 ++++ 9 files changed, 1444 insertions(+), 30 deletions(-) create mode 100644 compliance-core/src/csaf_ingest.rs create mode 100644 compliance-core/src/version.rs create mode 100644 compliance-core/tests/csaf_ingest.rs create mode 100644 compliance-core/tests/fixtures/csaf/README.md create mode 100644 compliance-core/tests/fixtures/csaf/icsa-26-260-07.json create mode 100644 compliance-core/tests/fixtures/csaf/ssa-240718.json create mode 100644 compliance-core/tests/fixtures/csaf/vde-synthetic.json diff --git a/compliance-agent/src/pipeline/nvd_cpe.rs b/compliance-agent/src/pipeline/nvd_cpe.rs index 7280b60..e460ab9 100644 --- a/compliance-agent/src/pipeline/nvd_cpe.rs +++ b/compliance-agent/src/pipeline/nvd_cpe.rs @@ -9,6 +9,8 @@ use std::collections::HashMap; use std::sync::{Arc, Mutex, OnceLock}; use std::time::{Duration, Instant}; +use compliance_core::version::cmp_dotted; + use crate::pipeline::public_http::{read_json, PublicHttp}; /// A product as NVD names it. @@ -244,36 +246,6 @@ fn version_matches(v: &str, r: &CpeRange) -> bool { ok } -/// Compare two dotted versions (`4.17.0.0` vs `4.9.0.0`); a missing -/// component counts as 0. -/// -/// A leading `r`/`v` is ignored (FatFs `r0.14b`, `V10.4.6`), and a component -/// is its number then any letter suffix, so `14` < `14b` < `15`. -fn cmp_dotted(a: &str, b: &str) -> std::cmp::Ordering { - let parts = |v: &str| -> Vec<(u64, String)> { - v.trim_start_matches(['r', 'R', 'v', 'V']) - .split('.') - .map(|part| { - let digits = - part.len() - part.trim_start_matches(|c: char| c.is_ascii_digit()).len(); - ( - part[..digits].parse().unwrap_or(0), - part[digits..].to_ascii_lowercase(), - ) - }) - .collect() - }; - let (pa, pb) = (parts(a), parts(b)); - let zero = (0, String::new()); - for i in 0..pa.len().max(pb.len()) { - match pa.get(i).unwrap_or(&zero).cmp(pb.get(i).unwrap_or(&zero)) { - std::cmp::Ordering::Equal => continue, - other => return other, - } - } - std::cmp::Ordering::Equal -} - #[cfg(test)] mod tests { use super::*; diff --git a/compliance-core/src/csaf_ingest.rs b/compliance-core/src/csaf_ingest.rs new file mode 100644 index 0000000..1d84493 --- /dev/null +++ b/compliance-core/src/csaf_ingest.rs @@ -0,0 +1,411 @@ +//! Vendor security advisories in CSAF 2.0 (CERT@VDE's vendor providers, +//! Siemens ProductCERT, CISA ICS; #515), read into what matching a target's +//! components needs: each product the advisory names (vendor, name, version +//! or `vers` range, CPE, purl, order numbers) and, per vulnerability, which +//! products are affected or fixed and what the vendor recommends. +//! +//! The product tree is walked as CSAF builds it: a `product_version` or +//! `product_version_range` branch is a product whose vendor, family and name +//! are its ancestors'; `full_product_names` and the products relationships +//! define (a component `installed_on` a platform) are products too. + +use serde::{Deserialize, Serialize}; + +use crate::version::{cmp_dotted, Vers}; + +/// A product an advisory names. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct AdvisoryProduct { + /// Its id in the advisory (`CSAFPID-51001`). + pub product_id: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub vendor: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub family: Option, + /// The product's name without its version (`CODESYS Control for Linux + /// SL`), or the full name where the tree gives no more. + pub name: String, + /// An exact version (`3.5.22.40`). + #[serde(default, skip_serializing_if = "Option::is_none")] + pub version: Option, + /// A version range in `vers` notation (`vers:generic/>=3.0.0.0|<3.5.22.40`). + #[serde(default, skip_serializing_if = "Option::is_none")] + pub version_range: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub cpe: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub purl: Option, + /// Order numbers (Siemens MLFB `6ES7518-4AX00-1AB0`) and SKUs. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub model_numbers: Vec, +} + +impl AdvisoryProduct { + /// Whether the product is `name` (compared as [`normalised_name`]) at + /// `version`: its exact version, or one its range contains. A product + /// without either covers every version of it. + pub fn covers(&self, name: &str, version: &str) -> bool { + if normalised_name(&self.name) != normalised_name(name) { + return false; + } + match (&self.version, &self.version_range) { + (Some(exact), _) => cmp_dotted(exact, version).is_eq(), + (None, Some(range)) => Vers::parse(range).is_some_and(|r| r.contains(version)), + (None, None) => true, + } + } +} + +/// A product name as advisories and SBOMs compare: lowercase, single spaces, +/// trimmed (`CODESYS Gateway ` is `codesys gateway`). +pub fn normalised_name(name: &str) -> String { + name.split_whitespace() + .collect::>() + .join(" ") + .to_lowercase() +} + +/// What the vendor recommends for some products. +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct Remediation { + /// CSAF's category: `vendor_fix`, `mitigation`, `workaround`, + /// `none_available`, `no_fix_planned`. + pub category: String, + pub details: String, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub url: Option, + #[serde(default)] + pub product_ids: Vec, +} + +/// One vulnerability of an advisory, as its products stand. +#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)] +pub struct AdvisoryVulnerability { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub cve: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub title: Option, + /// The vendor's description. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub summary: Option, + /// CVSS base severity (`HIGH`) and score, the highest the advisory gives. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub severity: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub cvss_score: Option, + /// `known_affected`, `first_affected`, `last_affected`. + #[serde(default)] + pub affected: Vec, + /// `fixed`, `first_fixed`. + #[serde(default)] + pub fixed: Vec, + #[serde(default)] + pub not_affected: Vec, + #[serde(default)] + pub under_investigation: Vec, + #[serde(default)] + pub recommended: Vec, + #[serde(default)] + pub remediations: Vec, +} + +/// An advisory, read for matching. +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct Advisory { + /// Its tracking id (`SSA-019113`, `VDE-2026-094`, `ICSA-26-260-07`). + pub id: String, + pub title: String, + pub publisher: String, + /// Where the vendor publishes it for people to read (a `self` + /// reference), the link its terms ask redistributions to carry. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub url: Option, + /// TLP label of its distribution (`WHITE`). + #[serde(default, skip_serializing_if = "Option::is_none")] + pub tlp: Option, + /// `current_release_date`, as written. + pub updated: String, + pub products: Vec, + pub vulnerabilities: Vec, +} + +/// Why a document is not an advisory to read. +#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)] +pub enum CsafError { + #[error("not a CSAF 2.0 document: {0}")] + NotCsaf(&'static str), +} + +impl Advisory { + /// The product with id `product_id`. + pub fn product(&self, product_id: &str) -> Option<&AdvisoryProduct> { + self.products.iter().find(|p| p.product_id == product_id) + } + + /// The exact versions of product `name` the vulnerability lists as fixed + /// (`3.5.22.40`), lowest first. + pub fn fixed_versions(&self, vulnerability: &AdvisoryVulnerability, name: &str) -> Vec { + let wanted = normalised_name(name); + let mut versions: Vec = vulnerability + .fixed + .iter() + .filter_map(|id| self.product(id)) + .filter(|p| normalised_name(&p.name) == wanted) + .filter_map(|p| p.version.clone()) + .collect(); + versions.sort_by(|a, b| cmp_dotted(a, b)); + versions.dedup(); + versions + } +} + +/// The text at `key` of `value`, trimmed, if not empty. +fn text(value: &serde_json::Value, key: &str) -> Option { + value + .get(key) + .and_then(|v| v.as_str()) + .map(str::trim) + .filter(|t| !t.is_empty()) + .map(str::to_string) +} + +/// The strings of the array at `key` of `value`. +fn strings(value: &serde_json::Value, key: &str) -> Vec { + value + .get(key) + .and_then(|v| v.as_array()) + .into_iter() + .flatten() + .filter_map(|v| v.as_str().map(str::to_string)) + .collect() +} + +/// A product from its `full_product_name` object and the names above it. +fn product( + full: &serde_json::Value, + vendor: Option<&str>, + family: Option<&str>, + name: Option<&str>, + version: Option<&str>, + version_range: Option<&str>, +) -> Option { + let product_id = text(full, "product_id")?; + let helper = full + .get("product_identification_helper") + .cloned() + .unwrap_or_default(); + let mut model_numbers = strings(&helper, "model_numbers"); + model_numbers.extend(strings(&helper, "skus")); + Some(AdvisoryProduct { + product_id, + vendor: vendor.map(str::to_string), + family: family.map(str::to_string), + name: name + .map(str::to_string) + .or_else(|| text(full, "name")) + .unwrap_or_default(), + version: version.map(str::to_string), + version_range: version_range.map(str::to_string), + cpe: text(&helper, "cpe"), + purl: text(&helper, "purl"), + model_numbers, + }) +} + +/// The products of a branch and those below it. +fn walk( + branch: &serde_json::Value, + vendor: Option<&str>, + family: Option<&str>, + name: Option<&str>, + out: &mut Vec, +) { + let category = branch + .get("category") + .and_then(|c| c.as_str()) + .unwrap_or(""); + let here = text(branch, "name"); + let here = here.as_deref(); + let (vendor, family, name) = match category { + "vendor" => (here, family, name), + "product_family" => (vendor, here, name), + "product_name" => (vendor, family, here), + _ => (vendor, family, name), + }; + if let Some(full) = branch.get("product") { + let (version, range) = match category { + "product_version" => (here, None), + "product_version_range" => (None, here), + _ => (None, None), + }; + if let Some(p) = product(full, vendor, family, name, version, range) { + out.push(p); + } + } + for child in branch + .get("branches") + .and_then(|b| b.as_array()) + .into_iter() + .flatten() + { + walk(child, vendor, family, name, out); + } +} + +/// Every product of `tree`. +fn products(tree: &serde_json::Value) -> Vec { + let mut out = Vec::new(); + walk(tree, None, None, None, &mut out); + let listed = tree + .get("full_product_names") + .and_then(|f| f.as_array()) + .into_iter() + .flatten(); + let related = tree + .get("relationships") + .and_then(|r| r.as_array()) + .into_iter() + .flatten() + .filter_map(|r| r.get("full_product_name")); + for full in listed.chain(related) { + if let Some(p) = product(full, None, None, None, None, None) { + if out.iter().all(|o| o.product_id != p.product_id) { + out.push(p); + } + } + } + out +} + +/// One vulnerability. +fn vulnerability(v: &serde_json::Value) -> AdvisoryVulnerability { + let status = v.get("product_status").cloned().unwrap_or_default(); + let ids = |keys: &[&str]| -> Vec { + let mut out: Vec = Vec::new(); + for key in keys { + for id in strings(&status, key) { + if !out.contains(&id) { + out.push(id); + } + } + } + out + }; + let summary = v + .get("notes") + .and_then(|n| n.as_array()) + .into_iter() + .flatten() + .find(|n| { + matches!( + n.get("category").and_then(|c| c.as_str()), + Some("description" | "summary") + ) + }) + .and_then(|n| text(n, "text")); + // The highest CVSS v3 (else v2) score the advisory gives. + let mut severity: Option = None; + let mut cvss_score: Option = None; + for score in v + .get("scores") + .and_then(|s| s.as_array()) + .into_iter() + .flatten() + { + let cvss = score.get("cvss_v3").or_else(|| score.get("cvss_v2")); + let Some(base) = cvss + .and_then(|c| c.get("baseScore")) + .and_then(|b| b.as_f64()) + else { + continue; + }; + if cvss_score.is_none_or(|s| base > s) { + cvss_score = Some(base); + severity = cvss.and_then(|c| text(c, "baseSeverity")); + } + } + let remediations = v + .get("remediations") + .and_then(|r| r.as_array()) + .into_iter() + .flatten() + .filter_map(|r| { + Some(Remediation { + category: text(r, "category")?, + details: text(r, "details").unwrap_or_default(), + url: text(r, "url"), + product_ids: strings(r, "product_ids"), + }) + }) + .collect(); + AdvisoryVulnerability { + cve: text(v, "cve"), + title: text(v, "title"), + summary, + severity, + cvss_score, + affected: ids(&["known_affected", "first_affected", "last_affected"]), + fixed: ids(&["fixed", "first_fixed"]), + not_affected: ids(&["known_not_affected"]), + under_investigation: ids(&["under_investigation"]), + recommended: ids(&["recommended"]), + remediations, + } +} + +/// Read a CSAF 2.0 document. +/// +/// # Errors +/// +/// [`CsafError::NotCsaf`] for a document without `document.csaf_version` +/// 2.0 or without a tracking id. +pub fn parse(doc: &serde_json::Value) -> Result { + let document = doc + .get("document") + .ok_or(CsafError::NotCsaf("no document"))?; + if document.get("csaf_version").and_then(|v| v.as_str()) != Some("2.0") { + return Err(CsafError::NotCsaf("csaf_version is not 2.0")); + } + let tracking = document.get("tracking").cloned().unwrap_or_default(); + let id = text(&tracking, "id").ok_or(CsafError::NotCsaf("no tracking id"))?; + // The page people read: of the `self` references (often the JSON, a + // PDF and a web page), the first that is neither, else the first. + let selves: Vec = document + .get("references") + .and_then(|r| r.as_array()) + .into_iter() + .flatten() + .filter(|r| r.get("category").and_then(|c| c.as_str()) == Some("self")) + .filter_map(|r| text(r, "url")) + .collect(); + let url = selves + .iter() + .find(|u| { + let lower = u.to_ascii_lowercase(); + !lower.ends_with(".json") && !lower.ends_with(".pdf") + }) + .or(selves.first()) + .cloned(); + Ok(Advisory { + id, + title: text(document, "title").unwrap_or_default(), + publisher: document + .get("publisher") + .and_then(|p| text(p, "name")) + .unwrap_or_default(), + url, + tlp: document + .get("distribution") + .and_then(|d| d.get("tlp")) + .and_then(|t| text(t, "label")), + updated: text(&tracking, "current_release_date").unwrap_or_default(), + products: doc.get("product_tree").map(products).unwrap_or_default(), + vulnerabilities: doc + .get("vulnerabilities") + .and_then(|v| v.as_array()) + .into_iter() + .flatten() + .map(vulnerability) + .collect(), + }) +} diff --git a/compliance-core/src/lib.rs b/compliance-core/src/lib.rs index 8cfd840..42b3fd5 100644 --- a/compliance-core/src/lib.rs +++ b/compliance-core/src/lib.rs @@ -1,6 +1,7 @@ pub mod config; pub mod control_check; pub mod csaf_docs; +pub mod csaf_ingest; pub mod db; pub mod enisa_docs; pub mod error; @@ -16,6 +17,7 @@ pub mod scan_matrix; pub mod telemetry; pub mod tenant; pub mod traits; +pub mod version; pub mod vex_docs; #[cfg(feature = "axum")] diff --git a/compliance-core/src/version.rs b/compliance-core/src/version.rs new file mode 100644 index 0000000..6fe5721 --- /dev/null +++ b/compliance-core/src/version.rs @@ -0,0 +1,215 @@ +//! Comparing versions as vendors write them, and version ranges in the purl +//! specification's `vers` notation (`vers:intdot/>=3.1.6|<3.1.7`), as CSAF +//! advisories state which product versions are affected (#515). + +use std::cmp::Ordering; + +/// Compare two dotted versions (`4.17.0.0` vs `4.9.0.0`); a missing +/// component counts as 0. +/// +/// A leading `r`/`v` is ignored (FatFs `r0.14b`, `V10.4.6`), and a component +/// is its number then any letter suffix, so `14` < `14b` < `15`. +pub fn cmp_dotted(a: &str, b: &str) -> Ordering { + let parts = |v: &str| -> Vec<(u64, String)> { + v.trim() + .trim_start_matches(['r', 'R', 'v', 'V']) + .split('.') + .map(|part| { + let digits = + part.len() - part.trim_start_matches(|c: char| c.is_ascii_digit()).len(); + ( + part[..digits].parse().unwrap_or(0), + part[digits..].to_ascii_lowercase(), + ) + }) + .collect() + }; + let (pa, pb) = (parts(a), parts(b)); + let zero = (0, String::new()); + for i in 0..pa.len().max(pb.len()) { + match pa.get(i).unwrap_or(&zero).cmp(pb.get(i).unwrap_or(&zero)) { + Ordering::Equal => continue, + other => return other, + } + } + Ordering::Equal +} + +/// A comparator of a `vers` constraint. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +enum Comparator { + Eq, + Ne, + Lt, + Le, + Gt, + Ge, +} + +/// A version range in `vers` notation. Versions compare as +/// [`cmp_dotted`] does, whatever the scheme (`generic`, `intdot`, `semver`): +/// vendor advisories use dotted numbers. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Vers { + /// Every version (`vers:all/*`, or a `*` constraint). + all: bool, + /// The constraints in their order. + constraints: Vec<(Comparator, String)>, +} + +impl Vers { + /// Parse `text`; `None` for anything that is not a `vers:` range with at + /// least one constraint. + pub fn parse(text: &str) -> Option { + let rest = text.trim().strip_prefix("vers:")?; + let (_scheme, constraints) = rest.split_once('/')?; + let mut all = false; + let mut parsed = Vec::new(); + for raw in constraints + .split('|') + .map(str::trim) + .filter(|c| !c.is_empty()) + { + if raw == "*" { + all = true; + continue; + } + let (comparator, version) = [ + (">=", Comparator::Ge), + ("<=", Comparator::Le), + ("!=", Comparator::Ne), + (">", Comparator::Gt), + ("<", Comparator::Lt), + ("=", Comparator::Eq), + ] + .iter() + .find_map(|(prefix, c)| raw.strip_prefix(prefix).map(|v| (*c, v))) + .unwrap_or((Comparator::Eq, raw)); + let version = version.trim(); + if version.is_empty() { + return None; + } + parsed.push((comparator, version.to_string())); + } + (all || !parsed.is_empty()).then_some(Self { + all, + constraints: parsed, + }) + } + + /// Whether `version` is in the range. + /// + /// Equality constraints decide first (`!=` excludes, `=` includes); the + /// bounds, sorted by version, form intervals: a lower bound (`>`, `>=`) + /// opens one, the next upper bound (`<`, `<=`) closes it, an upper bound + /// without a lower one is open below, a lower one without an upper one + /// open above. + pub fn contains(&self, version: &str) -> bool { + let eq = |v: &str| cmp_dotted(version, v) == Ordering::Equal; + if self + .constraints + .iter() + .any(|(c, v)| *c == Comparator::Ne && eq(v)) + { + return false; + } + if self.all + || self + .constraints + .iter() + .any(|(c, v)| *c == Comparator::Eq && eq(v)) + { + return true; + } + let mut bounds: Vec<&(Comparator, String)> = self + .constraints + .iter() + .filter(|(c, _)| !matches!(c, Comparator::Eq | Comparator::Ne)) + .collect(); + bounds.sort_by(|a, b| cmp_dotted(&a.1, &b.1)); + let above = |c: Comparator, v: &str| match c { + Comparator::Gt => cmp_dotted(version, v) == Ordering::Greater, + _ => cmp_dotted(version, v) != Ordering::Less, + }; + let below = |c: Comparator, v: &str| match c { + Comparator::Lt => cmp_dotted(version, v) == Ordering::Less, + _ => cmp_dotted(version, v) != Ordering::Greater, + }; + let mut lower: Option<&(Comparator, String)> = None; + let mut open_below = true; + for bound in bounds { + match bound.0 { + Comparator::Gt | Comparator::Ge => { + lower = Some(bound); + open_below = false; + } + _ => { + let in_lower = lower.is_none_or(|(c, v)| above(*c, v)); + if (open_below || lower.is_some()) && in_lower && below(bound.0, &bound.1) { + return true; + } + lower = None; + open_below = false; + } + } + } + lower.is_some_and(|(c, v)| above(*c, v)) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use std::cmp::Ordering::{Equal, Greater, Less}; + + fn vers(text: &str) -> Vers { + Vers::parse(text).unwrap_or_else(|| Vers { + all: false, + constraints: Vec::new(), + }) + } + + #[test] + fn dotted_versions_compare_by_number() { + assert_eq!(cmp_dotted("4.17.0.0", "4.9.0.0"), Greater); + assert_eq!(cmp_dotted("4.9.0.0", "4.17.0.0"), Less); + assert_eq!(cmp_dotted("3.5.18.0", "3.5.18.0"), Equal); + assert_eq!(cmp_dotted("4.2", "4.2.0.0"), Equal); + assert_eq!(cmp_dotted("r0.14b", "r0.16"), Less); + assert_eq!(cmp_dotted("V10.4.6", "10.4.6"), Equal); + } + + #[test] + fn ranges_as_vendor_advisories_write_them() { + // CODESYS: a closed range. + let codesys = vers("vers:generic/>=3.0.0.0|<3.5.22.40"); + assert!(codesys.contains("3.5.16.0")); + assert!(codesys.contains("3.0.0.0")); + assert!(!codesys.contains("3.5.22.40")); + assert!(!codesys.contains("4.17.0.0")); + // Siemens: open above. + let siemens = vers("vers:intdot/>=3.1.6"); + assert!(siemens.contains("3.2")); + assert!(!siemens.contains("3.1.5")); + // CISA: open below. + let cisa = vers("vers:intdot/<=1.5"); + assert!(cisa.contains("1.5")); + assert!(cisa.contains("0.9")); + assert!(!cisa.contains("1.6")); + // Two intervals, an exclusion, a single version, everything. + let two = vers("vers:generic/>=1.0|<1.4|>=2.0|<2.2"); + assert!(two.contains("1.2") && two.contains("2.1")); + assert!(!two.contains("1.5") && !two.contains("2.2")); + assert!(!vers("vers:generic/>=1.0|!=1.3|<2.0").contains("1.3")); + assert!(vers("vers:generic/1.3.2").contains("1.3.2")); + assert!(!vers("vers:generic/1.3.2").contains("1.3.3")); + assert!(vers("vers:all/*").contains("9.9")); + } + + #[test] + fn what_is_not_a_range_is_refused() { + assert_eq!(Vers::parse("3.5.16.0"), None); + assert_eq!(Vers::parse("vers:generic/"), None); + assert_eq!(Vers::parse("vers:generic/>="), None); + } +} diff --git a/compliance-core/tests/csaf_ingest.rs b/compliance-core/tests/csaf_ingest.rs new file mode 100644 index 0000000..a200843 --- /dev/null +++ b/compliance-core/tests/csaf_ingest.rs @@ -0,0 +1,148 @@ +//! #515: vendor CSAF advisories read for matching: products with their +//! versions, ranges and identifiers, per vulnerability the affected and fixed +//! products and the vendor's remediation. Fixtures: a CISA ICS advisory, a +//! Siemens ProductCERT advisory (see the fixture README for the sources) and +//! a synthetic advisory shaped like CERT@VDE's. + +#![allow(clippy::expect_used, clippy::unwrap_used)] + +use compliance_core::csaf_ingest::{normalised_name, parse, Advisory}; + +fn fixture(name: &str) -> Advisory { + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("tests/fixtures/csaf") + .join(name); + let doc: serde_json::Value = + serde_json::from_str(&std::fs::read_to_string(path).unwrap()).unwrap(); + parse(&doc).unwrap() +} + +#[test] +fn a_vendor_advisory_gives_ranges_fixes_and_remediations() { + let a = fixture("vde-synthetic.json"); + assert_eq!(a.id, "VDE-2026-9001"); + assert_eq!(a.tlp.as_deref(), Some("WHITE")); + // The readable page, not the JSON. + assert_eq!( + a.url.as_deref(), + Some("https://certvde.com/en/advisories/VDE-2026-9001") + ); + let affected = a.product("CSAFPID-51001").unwrap(); + assert_eq!(affected.vendor.as_deref(), Some("Example")); + assert_eq!(affected.family.as_deref(), Some("Software")); + assert_eq!( + normalised_name(&affected.name), + "example control for linux sl" + ); + assert!(affected.cpe.is_some()); + // A runtime below the fix is covered, the fix itself and newer are not. + assert!(affected.covers("Example Control for Linux SL", "3.5.16.0")); + assert!(!affected.covers("Example Control for Linux SL", "3.5.22.40")); + assert!(!affected.covers("Example Gateway", "3.5.16.0")); + let v = &a.vulnerabilities[0]; + assert_eq!(v.cve.as_deref(), Some("CVE-2026-90001")); + assert_eq!(v.affected, ["CSAFPID-51001"]); + assert_eq!(v.severity.as_deref(), Some("HIGH")); + assert_eq!(v.cvss_score, Some(7.5)); + assert_eq!( + v.summary.as_deref(), + Some("A crafted request can crash the runtime.") + ); + assert_eq!(v.remediations[0].category, "vendor_fix"); + assert_eq!( + a.fixed_versions(v, "Example Control for Linux SL"), + ["3.5.22.40"] + ); +} + +#[test] +fn a_siemens_advisory_covers_every_version_of_its_family() { + let a = fixture("ssa-240718.json"); + assert_eq!(a.id, "SSA-240718"); + assert_eq!( + a.url.as_deref(), + Some("https://cert-portal.siemens.com/productcert/html/ssa-240718.html") + ); + let p = &a.products[0]; + assert_eq!(p.vendor.as_deref(), Some("Siemens")); + assert_eq!(p.version_range.as_deref(), Some("vers:all/*")); + assert!(p.covers(&p.name.clone(), "2.2")); + let v = &a.vulnerabilities[0]; + assert_eq!(v.cve.as_deref(), Some("CVE-2012-3037")); + let categories: Vec<&str> = v.remediations.iter().map(|r| r.category.as_str()).collect(); + assert_eq!(categories, ["mitigation", "no_fix_planned"]); +} + +#[test] +fn a_cisa_advisory_names_products_without_identifiers() { + let a = fixture("icsa-26-260-07.json"); + assert_eq!(a.id, "ICSA-26-260-07"); + assert_eq!( + a.url.as_deref(), + Some("https://www.cisa.gov/news-events/ics-advisories/icsa-26-260-07") + ); + let powerchute: Vec<_> = a + .products + .iter() + .filter(|p| p.vendor.as_deref() == Some("Schneider Electric")) + .collect(); + assert!(powerchute + .iter() + .any(|p| p.version_range.as_deref() == Some("vers:intdot/<=1.5"))); + assert!(powerchute + .iter() + .any(|p| p.version.as_deref() == Some("1.6"))); + assert!(powerchute + .iter() + .all(|p| p.cpe.is_none() && p.model_numbers.is_empty())); + assert!(!a.vulnerabilities.is_empty()); + assert!(a.vulnerabilities.iter().all(|v| v.cve.is_some())); +} + +#[test] +fn what_is_not_csaf_is_refused() { + assert!(parse(&serde_json::json!({ "document": { "csaf_version": "2.1" } })).is_err()); + assert!(parse(&serde_json::json!({})).is_err()); +} + +/// The newest advisory of each default provider, fetched live and read: +/// `cargo test -p compliance-core --test csaf_ingest -- --ignored`. +#[test] +#[ignore = "fetches from the providers"] +fn live_advisories_of_the_default_providers_are_read() { + let get = |url: &str| -> serde_json::Value { + let out = std::process::Command::new("curl") + .args(["-sSfL", "--max-time", "60", url]) + .output() + .expect("curl runs"); + assert!(out.status.success(), "{url}"); + serde_json::from_slice(&out.stdout).unwrap() + }; + for feed in [ + "https://codesys.csaf-tp.certvde.com/.well-known/csaf/white/csaf-feed-tlp-white.json", + "https://cert-portal.siemens.com/productcert/csaf/ssa-feed-tlp-white.json", + "https://raw.githubusercontent.com/cisagov/CSAF/develop/csaf_files/OT/white/cisa-csaf-ot-feed-tlp-white.json", + ] { + let feed = get(feed); + let entry = &feed["feed"]["entry"][0]; + let url = entry["link"] + .as_array() + .unwrap() + .iter() + .find(|l| l["rel"] == "self") + .and_then(|l| l["href"].as_str()) + .unwrap() + .to_string(); + let advisory = parse(&get(&url)).unwrap(); + println!( + "{} {}: {} products, {} vulnerabilities, {:?}", + advisory.publisher, + advisory.id, + advisory.products.len(), + advisory.vulnerabilities.len(), + advisory.url + ); + assert!(!advisory.products.is_empty()); + assert!(!advisory.vulnerabilities.is_empty()); + } +} diff --git a/compliance-core/tests/fixtures/csaf/README.md b/compliance-core/tests/fixtures/csaf/README.md new file mode 100644 index 0000000..db68e2e --- /dev/null +++ b/compliance-core/tests/fixtures/csaf/README.md @@ -0,0 +1,9 @@ +# CSAF advisory fixtures (#515) + +| File | Source | Terms | +|---|---|---| +| `icsa-26-260-07.json` | CISA ICS advisory ICSA-26-260-07, from https://raw.githubusercontent.com/cisagov/CSAF/develop/csaf_files/OT/white/2026/icsa-26-260-07.json (original: https://www.cisa.gov/news-events/ics-advisories/icsa-26-260-07) | US government work; CISA notification and privacy & use policy | +| `ssa-240718.json` | Siemens ProductCERT SSA-240718, from https://cert-portal.siemens.com/productcert/csaf/ssa-240718.json (original: https://cert-portal.siemens.com/productcert/html/ssa-240718.html) | Siemens Security Advisories terms of use (https://www.siemens.com/productcert/terms-of-use): redistribution allowed with a link to the original, given here | +| `vde-synthetic.json` | Written for these tests in the shape of CERT@VDE's vendor advisories; every name, id and CVE is made up | ours | + +Unchanged copies of the published documents; replace them only by copying the upstream file again. diff --git a/compliance-core/tests/fixtures/csaf/icsa-26-260-07.json b/compliance-core/tests/fixtures/csaf/icsa-26-260-07.json new file mode 100644 index 0000000..aeac8a2 --- /dev/null +++ b/compliance-core/tests/fixtures/csaf/icsa-26-260-07.json @@ -0,0 +1,417 @@ +{ + "document": { + "acknowledgments": [ + { + "organization": "Schneider Electric CPCERT", + "summary": "reported this vulnerability to CISA." + } + ], + "category": "csaf_security_advisory", + "csaf_version": "2.0", + "distribution": { + "text": "Disclosure is not limited", + "tlp": { + "label": "WHITE", + "url": "https://www.cisa.gov/news-events/news/traffic-light-protocol-tlp-definitions-and-usage" + } + }, + "lang": "en-US", + "notes": [ + { + "category": "general", + "text": "We strongly recommend the following industry cybersecurity best practices.\n\nhttps://www.se.com/us/en/download/document/7EN52-0390/\n* Locate control and safety system networks and remote devices behind firewalls and isolate them from the business network.\n* Install physical controls so no unauthorized personnel can access your industrial control and safety systems, components, peripheral equipment, and networks.\n* Place all controllers in locked cabinets and never leave them in the \u201cProgram\u201d mode.\n* Never connect programming software to any network other than the network intended for that device.\n* Scan all methods of mobile data exchange with the isolated network such as CDs, USB drives, etc. before use in the terminals or any node connected to these networks.\n* Never allow mobile devices that have connected to any other network besides the intended network to connect to the safety or control networks without proper sanitation.\n* Minimize network exposure for all control system devices and systems and ensure that they are not accessible from the Internet.\n* When remote access is required, use secure methods, such as Virtual Private Networks (VPNs). Recognize that VPNs may have vulnerabilities and should be updated to the most current version available. Also, understand that VPNs are only as secure as the connected devices.\nFor more information refer to the Schneider Electric Recommended Cybersecurity Best Practices document. \n", + "title": "General Security Recommendations" + }, + { + "category": "general", + "text": "This document provides an overview of the identified vulnerability or vulnerabilities and actions required to mitigate. For more details and assistance on how to protect your installation, contact your local Schneider Electric representative or Schneider Electric Industrial Cybersecurity Services: https://www.se.com/ww/en/work/solutions/cybersecurity/. These organizations will be fully aware of this situation and can support you through the process.\nFor further information related to cybersecurity in Schneider Electric\u2019s products, visit the company\u2019s cybersecurity support portal page: https://www.se.com/ww/en/work/support/cybersecurity/overview.jsp", + "title": "For More Information" + }, + { + "category": "legal_disclaimer", + "text": "THIS NOTIFICATION DOCUMENT, THE INFORMATION CONTAINED HEREIN, AND ANY MATERIALS LINKED FROM IT (COLLECTIVELY, THIS \u201cNOTIFICATION\u201d) ARE INTENDED TO HELP PROVIDE AN OVERVIEW OF THE IDENTIFIED SITUATION AND SUGGESTED MITIGATION ACTIONS, REMEDIATION, FIX, AND/OR GENERAL SECURITY RECOMMENDATIONS AND IS PROVIDED ON AN \u201cAS-IS\u201d BASIS WITHOUT WARRANTY OR GUARANTEE OF ANY KIND. SCHNEIDER ELECTRIC DISCLAIMS ALL WARRANTIES RELATING TO THIS NOTIFICATION, EITHER EXPRESS OR IMPLIED, INCLUDING WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SCHNEIDER ELECTRIC MAKES NO WARRANTY THAT THE NOTIFICATION WILL RESOLVE THE IDENTIFIED SITUATION. IN NO EVENT SHALL SCHNEIDER ELECTRIC BE LIABLE FOR ANY DAMAGES OR LOSSES WHATSOEVER IN CONNECTION WITH THIS NOTIFICATION, INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF SCHNEIDER ELECTRIC HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. YOUR USE OF THIS NOTIFICATION IS AT YOUR OWN RISK, AND YOU ARE SOLELY LIABLE FOR ANY DAMAGES TO YOUR SYSTEMS OR ASSETS OR OTHER LOSSES THAT MAY RESULT FROM YOUR USE OF THIS NOTIFICATION. SCHNEIDER ELECTRIC RESERVES THE RIGHT TO UPDATE OR CHANGE THIS NOTIFICATION AT ANY TIME AND IN ITS SOLE DISCRETION", + "title": "LEGAL DISCLAIMER" + }, + { + "category": "general", + "text": "Schneider's purpose is to create Impact by empowering all to make the most of our energy and resources, bridging progress and\r\nsustainability for all. We call this Life Is On.\n\nOur mission is to be the trusted partner in Sustainability and Efficiency.\n\nWe are a global industrial technology leader bringing world-leading expertise in electrification, automation and digitization to smart\r\nindustries, resilient infrastructure, future-proof data centers, intelligent buildings, and intuitive homes. Anchored by our deep\r\ndomain expertise, we provide integrated end-to-end lifecycle AI enabled Industrial IoT solutions with connected products, automation,\r\nsoftware and services, delivering digital twins to enable profitable growth for our customers.\n\nWe are a people company with an ecosystem of 150,000 colleagues and more than a million partners operating in over 100 countries\r\nto ensure proximity to our customers and stakeholders. We embrace diversity and inclusion in everything we do, guided by our\r\nmeaningful purpose of a sustainable future for all. \n\n www.se.com", + "title": "About Schneider Electric" + }, + { + "category": "summary", + "text": "Schneider Electric is aware of vulnerabilities in its PowerChute\u2122 Serial Shutdown product. \r\nThe PowerChute Serial Shutdown product is a UPS management software enabling graceful system shutdown and energy management capabilities for desktops, servers and workstations. \r\nFailure to apply the remediation provided below may risk improper authentication validation which could result in disruption of operations and access to system data.", + "title": "Overview" + }, + { + "category": "other", + "text": "The severity of vulnerabilities was calculated using the CVSS Base metrics for 4.0 ([CVSS v4.0](https://www.first.org/cvss/calculator/4.0)). CVSS v3.1 \nwill be still evaluated until the adoption of CVSS v4.0 by the industry. The severity was calculated without \nincorporating the Temporal and Environmental metrics. Schneider Electric recommends that customers score the CVSS Environmental metrics, which are specific to end-user organizations, and consider factors such as \nthe presence of mitigations in that environment. Environmental metrics may refine the relative severity posed by the vulnerabilities described in this document within a customer's environment." + }, + { + "category": "other", + "text": "Customers should use appropriate patching methodologies when applying these patches to their systems. We strongly recommend the use of back-ups and evaluating the impact of these patches in a Test and Development environment or on an offline infrastructure. Contact Schneider Electric's [Customer Care Center](https://www.se.com/us/en/work/support/contacts.jsp) if you need assistance removing a patch." + }, + { + "category": "legal_disclaimer", + "text": "This product is provided subject to this Notification (https://www.cisa.gov/notification) and this Privacy & Use policy (https://www.cisa.gov/privacy-policy).", + "title": "Legal Notice and Terms of Use" + }, + { + "category": "other", + "text": "This ICSA is a verbatim republication of Schneider Electric CPCERT SEVD-2026-223-01 from a direct conversion of the vendor's Common Security Advisory Framework (CSAF) advisory. This is republished to CISA's website as a means of increasing visibility and is provided \"as-is\" for informational purposes only. CISA is not responsible for the editorial or technical accuracy of republished advisories and provides no warranties of any kind regarding any information contained within this advisory. Further, CISA does not endorse any commercial product or service. Please contact Schneider Electric CPCERT directly for any questions regarding this advisory.", + "title": "Advisory Conversion Disclaimer" + }, + { + "category": "general", + "text": "CISA recommends users take defensive measures to minimize the exploitation risk of these vulnerabilities.", + "title": "Recommended Practices" + }, + { + "category": "general", + "text": "Minimize network exposure for all control system devices and/or systems, and ensure they are not accessible from the internet.", + "title": "Recommended Practices" + }, + { + "category": "general", + "text": "Locate control system networks and remote devices behind firewalls and isolate them from business networks.", + "title": "Recommended Practices" + }, + { + "category": "general", + "text": "When remote access is required, use more secure methods, such as Virtual Private Networks (VPNs), recognizing VPNs may have vulnerabilities and should be updated to the most recent version available. Also recognize VPN is only as secure as its connected devices.", + "title": "Recommended Practices" + }, + { + "category": "general", + "text": "CISA reminds organizations to perform proper impact analysis and risk assessment prior to deploying defensive measures.", + "title": "Recommended Practices" + }, + { + "category": "general", + "text": "CISA also provides a section for control systems security recommended practices on the ICS webpage on cisa.gov. Several CISA products detailing cyber defense best practices are available for reading and download, including Improving Industrial Control Systems Cybersecurity with Defense-in-Depth Strategies.", + "title": "Recommended Practices" + }, + { + "category": "general", + "text": "CISA encourages organizations to implement recommended cybersecurity strategies for proactive defense of ICS assets. Additional mitigation guidance and recommended practices are publicly available on the ICS webpage at cisa.gov in the technical information paper, ICS-TIP-12-146-01B--Targeted Cyber Intrusion Detection and Mitigation Strategies.", + "title": "Recommended Practices" + }, + { + "category": "general", + "text": "Organizations observing suspected malicious activity should follow established internal procedures and report findings to CISA for tracking and correlation against other incidents.", + "title": "Recommended Practices" + }, + { + "category": "other", + "text": "Commercial Facilities, Critical Manufacturing, Energy, Information Technology", + "title": "Critical infrastructure sectors" + }, + { + "category": "other", + "text": "Worldwide", + "title": "Countries/areas deployed" + }, + { + "category": "other", + "text": "France", + "title": "Company headquarters location" + } + ], + "publisher": { + "category": "other", + "contact_details": "central@cisa.dhs.gov", + "name": "CISA", + "namespace": "https://www.cisa.gov/" + }, + "references": [ + { + "category": "self", + "summary": "Improper Restriction of Excessive Authentication Attempts vulnerability on PowerChute Serial Shutdown - SEVD-2026-223-01 CSAF Version", + "url": "https://download.schneider-electric.com/files?p_Doc_Ref=SEVD-2026-223-01&p_enDocType=Security+and+Safety+Notice&p_File_Name=sevd-2026-223-01.json" + }, + { + "category": "self", + "summary": "Improper Restriction of Excessive Authentication Attempts vulnerability on PowerChute Serial Shutdown - SEVD-2026-223-01 PDF Version", + "url": "https://download.schneider-electric.com/files?p_Doc_Ref=SEVD-2026-223-01&p_enDocType=Security+and+Safety+Notice&p_File_Name=SEVD-2026-223-01.pdf" + }, + { + "category": "external", + "summary": "Recommended Cybersecurity Best Practices", + "url": "https://www.se.com/ww/en/download/document/7EN52-0390" + }, + { + "category": "self", + "summary": "ICS Advisory ICSA-26-260-07 JSON", + "url": "https://raw.githubusercontent.com/cisagov/CSAF/develop/csaf_files/OT/white/2026/icsa-26-260-07.json" + }, + { + "category": "self", + "summary": "ICS Advisory ICSA-26-260-07 - Web Version", + "url": "https://www.cisa.gov/news-events/ics-advisories/icsa-26-260-07" + }, + { + "category": "external", + "summary": "Recommended Practices", + "url": "https://www.cisa.gov/news-events/ics-alerts/ics-alert-10-301-01" + }, + { + "category": "external", + "summary": "Recommended Practices", + "url": "https://www.cisa.gov/resources-tools/resources/ics-recommended-practices" + }, + { + "category": "external", + "summary": "Recommended Practices", + "url": "https://www.cisa.gov/topics/industrial-control-systems" + }, + { + "category": "external", + "summary": "Recommended Practices", + "url": "https://www.cisa.gov/sites/default/files/recommended_practices/NCCIC_ICS-CERT_Defense_in_Depth_2016_S508C.pdf" + }, + { + "category": "external", + "summary": "Recommended Practices", + "url": "https://www.cisa.gov/sites/default/files/publications/Cybersecurity_Best_Practices_for_Industrial_Control_Systems.pdf" + }, + { + "category": "external", + "summary": "Recommended Practices", + "url": "https://www.cisa.gov/news-events/news/targeted-cyber-intrusion-detection-and-mitigation-strategies-update-b" + } + ], + "title": "Schneider Electric PowerChute Serial Shutdown", + "tracking": { + "current_release_date": "2026-09-17T06:00:00.000000Z", + "generator": { + "date": "2026-09-02T14:49:15.027471Z", + "engine": { + "name": "CISA CSAF Generator", + "version": "1.5.0" + } + }, + "id": "ICSA-26-260-07", + "initial_release_date": "2026-08-11T07:00:00.000000Z", + "revision_history": [ + { + "date": "2026-08-11T07:00:00.000000Z", + "legacy_version": "Initial", + "number": "1", + "summary": "Original Release" + }, + { + "date": "2026-09-17T06:00:00.000000Z", + "legacy_version": "CISA Republication", + "number": "2", + "summary": "Initial CISA Republication of Schneider Electric CPCERT SEVD-2026-223-01 advisory" + } + ], + "status": "final", + "version": "2" + } + }, + "product_tree": { + "branches": [ + { + "branches": [ + { + "branches": [ + { + "category": "product_version_range", + "name": "vers:intdot/<=1.5", + "product": { + "name": "PowerChute\u2122 Serial Shutdown Version 1.5 and prior", + "product_id": "CSAFPID-0001" + } + }, + { + "category": "product_version", + "name": "1.6", + "product": { + "name": "PowerChute\u2122 Serial Shutdown Version 1.6", + "product_id": "CSAFPID-0002" + } + } + ], + "category": "product_name", + "name": "PowerChute\u2122 Serial Shutdown" + } + ], + "category": "vendor", + "name": "Schneider Electric" + }, + { + "branches": [ + { + "category": "product_name", + "name": "Windows", + "product": { + "name": "Microsoft Windows", + "product_id": "CSAFPID-0003" + } + } + ], + "category": "vendor", + "name": "Microsoft" + }, + { + "branches": [ + { + "category": "product_name", + "name": "Enterprise Linux", + "product": { + "name": "Red Hat Enterprise Linux", + "product_id": "CSAFPID-0004" + } + } + ], + "category": "vendor", + "name": "Red Hat" + }, + { + "branches": [ + { + "category": "product_name", + "name": "Enterprise Linux", + "product": { + "name": "SUSE Enterprise Linux", + "product_id": "CSAFPID-0005" + } + } + ], + "category": "vendor", + "name": "SUSE" + } + ], + "relationships": [ + { + "category": "installed_on", + "full_product_name": { + "name": "PowerChute\u2122 Serial Shutdown Version 1.6 installed on Microsoft Windows", + "product_id": "CSAFPID-0006" + }, + "product_reference": "CSAFPID-0002", + "relates_to_product_reference": "CSAFPID-0003" + }, + { + "category": "installed_on", + "full_product_name": { + "name": "PowerChute\u2122 Serial Shutdown Version 1.6 installed on Red Hat Enterprise Linux", + "product_id": "CSAFPID-0007" + }, + "product_reference": "CSAFPID-0002", + "relates_to_product_reference": "CSAFPID-0004" + }, + { + "category": "installed_on", + "full_product_name": { + "name": "PowerChute\u2122 Serial Shutdown Version 1.6 installed on SUSE Enterprise Linux", + "product_id": "CSAFPID-0008" + }, + "product_reference": "CSAFPID-0002", + "relates_to_product_reference": "CSAFPID-0005" + } + ] + }, + "vulnerabilities": [ + { + "acknowledgments": [ + { + "names": [ + "Internally Found" + ], + "organization": "Schneider Electric" + } + ], + "cve": "CVE-2026-13348", + "cwe": { + "id": "CWE-307", + "name": "Improper Restriction of Excessive Authentication Attempts" + }, + "notes": [ + { + "category": "description", + "text": "CWE-307: Improper Restriction of Excessive Authentication Attempts vulnerability exists that could allow an attacker to gain unauthorized access to a user account by performing an arbitrary number of authentication attempts when redirect handling is disabled.", + "title": "CVE Description" + }, + { + "category": "details", + "text": "CVSS v4.0 Base Score 6.9 | Medium | [CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N](https://www.first.org/cvss/calculator/4.0#CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N)", + "title": "CVSS v4.0 Score" + } + ], + "product_status": { + "fixed": [ + "CSAFPID-0006", + "CSAFPID-0007", + "CSAFPID-0008" + ], + "known_affected": [ + "CSAFPID-0001" + ] + }, + "references": [ + { + "category": "external", + "summary": "www.cve.org", + "url": "https://www.cve.org/CVERecord?id=CVE-2026-13348" + }, + { + "category": "external", + "summary": "cwe.mitre.org", + "url": "https://cwe.mitre.org/data/definitions/307.html" + }, + { + "category": "external", + "summary": "www.first.org", + "url": "https://www.first.org/cvss/calculator/3.1#CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N" + } + ], + "remediations": [ + { + "category": "vendor_fix", + "details": "Version v1.6 of PowerChute\u2122 Serial Shutdown includes a fix for these vulnerabilities and is available for download here:\n\u2022 Windows: https://www.se.com/ww/en/download/document/SPD-PCSS_WIN_EN/ \n\n Reboot needed: Upon installation, the service is automatically restarted. A \ncustomer can validate a successful install by checking the version \ninformation in the Control Panel or on the About page within PCSS after \nlogging in.\nSpecific instructions and hardening guidelines for these remediations can\nbe found in the [Security Handbook](https://download.se.com/files?p_Doc_Ref=SPD_CCON-PCSSSH_EN).", + "product_ids": [ + "CSAFPID-0001" + ], + "restart_required": { + "category": "service" + }, + "url": "https://www.se.com/ww/en/download/document/SPD-PCSS_WIN_EN/" + }, + { + "category": "vendor_fix", + "details": "Version v1.6 of PowerChute\u2122 Serial Shutdown includes a fix for these vulnerabilities and is available for download here:\n\u2022 Linux: https://www.se.com/ww/en/download/document/SPD-PCSS_LNX_EN/ \n\n Reboot needed: Upon installation, the service is automatically restarted. A \ncustomer can validate a successful install by checking the version \ninformation in the Control Panel or on the About page within PCSS after \nlogging in.\nSpecific instructions and hardening guidelines for these remediations can\nbe found in the [Security Handbook](https://download.se.com/files?p_Doc_Ref=SPD_CCON-PCSSSH_EN).", + "product_ids": [ + "CSAFPID-0001" + ], + "restart_required": { + "category": "service" + }, + "url": "https://www.se.com/ww/en/download/document/SPD-PCSS_LNX_EN/" + } + ], + "scores": [ + { + "cvss_v3": { + "attackComplexity": "LOW", + "attackVector": "NETWORK", + "availabilityImpact": "NONE", + "baseScore": 5.3, + "baseSeverity": "MEDIUM", + "confidentialityImpact": "LOW", + "integrityImpact": "NONE", + "privilegesRequired": "NONE", + "scope": "UNCHANGED", + "userInteraction": "NONE", + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N", + "version": "3.1" + }, + "products": [ + "CSAFPID-0001" + ] + } + ], + "title": "CVE-2026-13348" + } + ] +} \ No newline at end of file diff --git a/compliance-core/tests/fixtures/csaf/ssa-240718.json b/compliance-core/tests/fixtures/csaf/ssa-240718.json new file mode 100644 index 0000000..dddc956 --- /dev/null +++ b/compliance-core/tests/fixtures/csaf/ssa-240718.json @@ -0,0 +1,162 @@ +{ + "document": { + "category": "csaf_security_advisory", + "csaf_version": "2.0", + "distribution": { + "text": "Disclosure is not limited. (TLPv2: TLP:CLEAR)", + "tlp": { + "label": "WHITE" + } + }, + "lang": "en", + "notes": [ + { + "category": "summary", + "text": "SIMATIC S7-1200 CPU V2 devices contain an insufficiently protected private key used for the Certificate Authority (CA) for HTTPS connections. Possession of this key could allow remote attackers to spoof the device's web server by creating a forged web server certificate.\n\nSiemens recommends specific countermeasures for products where fixes are not, or not yet available.\nRefer to the chapter Additional Information for more details.", + "title": "Summary" + }, + { + "category": "general", + "text": "As a general security measure, Siemens strongly recommends to protect network access to devices with appropriate mechanisms. In order to operate the devices in a protected IT environment, Siemens recommends to configure the environment according to Siemens' operational guidelines for Industrial Security (Download: https://www.siemens.com/cert/operational-guidelines-industrial-security), and to follow the recommendations in the product manuals.\nAdditional information on Industrial Security by Siemens can be found at: https://www.siemens.com/industrialsecurity", + "title": "General Recommendations" + }, + { + "category": "general", + "text": "For further inquiries on security vulnerabilities in Siemens products and solutions, please contact the Siemens ProductCERT: https://www.siemens.com/cert/advisories", + "title": "Additional Resources" + }, + { + "category": "legal_disclaimer", + "text": "The use of Siemens Security Advisories is subject to the terms and conditions listed on: https://www.siemens.com/productcert/terms-of-use.", + "title": "Terms of Use" + } + ], + "publisher": { + "category": "vendor", + "contact_details": "productcert@siemens.com", + "name": "Siemens ProductCERT", + "namespace": "https://www.siemens.com" + }, + "references": [ + { + "category": "self", + "summary": "SSA-240718: Insecure Storage of HTTPS CA Certificate in SIMATIC S7-1200 CPU V2 - HTML Version", + "url": "https://cert-portal.siemens.com/productcert/html/ssa-240718.html" + }, + { + "category": "self", + "summary": "SSA-240718: Insecure Storage of HTTPS CA Certificate in SIMATIC S7-1200 CPU V2 - CSAF Version", + "url": "https://cert-portal.siemens.com/productcert/csaf/ssa-240718.json" + } + ], + "title": "SSA-240718: Insecure Storage of HTTPS CA Certificate in SIMATIC S7-1200 CPU V2", + "tracking": { + "current_release_date": "2025-10-14T00:00:00Z", + "generator": { + "engine": { + "name": "Siemens ProductCERT CSAF Generator", + "version": "1" + } + }, + "id": "SSA-240718", + "initial_release_date": "2012-09-13T00:00:00Z", + "revision_history": [ + { + "date": "2012-09-13T00:00:00Z", + "legacy_version": "1.0", + "number": "1", + "summary": "Publication Date" + }, + { + "date": "2020-02-10T00:00:00Z", + "legacy_version": "1.1", + "number": "2", + "summary": "SIPLUS devices now explicitly mentioned in the list of affected products" + }, + { + "date": "2025-10-14T00:00:00Z", + "legacy_version": "1.2", + "number": "3", + "summary": "Used CVE ID (CVE-2012-3037) instead of the deprecated SVE ID (SVE-2012-0003); Corrected CVSS vector of CVE-2012-3037; Updated SSA to current data model and support of csaf" + } + ], + "status": "final", + "version": "3" + } + }, + "product_tree": { + "branches": [ + { + "branches": [ + { + "branches": [ + { + "category": "product_version_range", + "name": "vers:all/*", + "product": { + "name": "SIMATIC S7-1200 CPU V2 family (incl. SIPLUS variants)", + "product_id": "1" + } + } + ], + "category": "product_name", + "name": "SIMATIC S7-1200 CPU V2 family (incl. SIPLUS variants)" + } + ], + "category": "vendor", + "name": "Siemens" + } + ] + }, + "vulnerabilities": [ + { + "cve": "CVE-2012-3037", + "cwe": { + "id": "CWE-321", + "name": "Use of Hard-coded Cryptographic Key" + }, + "notes": [ + { + "category": "summary", + "text": "Affected devices do not properly protect the private key of the integrated Certification Authority (CA) certificate. Possession of this key could allow remote attackers to spoof the device's web server by creating a forged web server certificate.", + "title": "Summary" + } + ], + "product_status": { + "known_affected": [ + "1" + ] + }, + "remediations": [ + { + "category": "mitigation", + "details": "Uninstall the affected CA keys from the browser's certificate store.", + "product_ids": [ + "1" + ] + }, + { + "category": "no_fix_planned", + "details": "Currently no fix is planned", + "product_ids": [ + "1" + ] + } + ], + "scores": [ + { + "cvss_v3": { + "baseScore": 7.4, + "baseSeverity": "HIGH", + "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N", + "version": "3.1" + }, + "products": [ + "1" + ] + } + ], + "title": "CVE-2012-3037" + } + ] +} \ No newline at end of file diff --git a/compliance-core/tests/fixtures/csaf/vde-synthetic.json b/compliance-core/tests/fixtures/csaf/vde-synthetic.json new file mode 100644 index 0000000..24e4572 --- /dev/null +++ b/compliance-core/tests/fixtures/csaf/vde-synthetic.json @@ -0,0 +1,78 @@ +{ + "document": { + "category": "csaf_security_advisory", + "csaf_version": "2.0", + "title": "Example PLC runtime: a synthetic advisory shaped like CERT@VDE's", + "publisher": { + "category": "vendor", + "name": "Example Automation GmbH", + "namespace": "https://example.invalid" + }, + "distribution": { "tlp": { "label": "WHITE", "url": "https://www.first.org/tlp/" } }, + "references": [ + { "category": "self", "summary": "CSAF", "url": "https://example.invalid/csaf/white/2026/vde-2026-9001.json" }, + { "category": "self", "summary": "Advisory", "url": "https://certvde.com/en/advisories/VDE-2026-9001" } + ], + "tracking": { + "id": "VDE-2026-9001", + "status": "final", + "version": "1", + "current_release_date": "2026-10-01T08:00:00.000Z", + "initial_release_date": "2026-10-01T08:00:00.000Z", + "revision_history": [{ "date": "2026-10-01T08:00:00.000Z", "number": "1", "summary": "Initial" }] + } + }, + "product_tree": { + "branches": [ + { + "category": "vendor", + "name": "Example", + "branches": [ + { + "category": "product_family", + "name": "Software", + "branches": [ + { + "category": "product_name", + "name": "Example Control for Linux SL ", + "branches": [ + { + "category": "product_version_range", + "name": "vers:generic/>=3.0.0.0|<3.5.22.40", + "product": { + "name": "Example Control for Linux SL <3.5.22.40", + "product_id": "CSAFPID-51001", + "product_identification_helper": { "cpe": "cpe:2.3:a:example:example_control_for_linux_sl:*:*:*:*:*:*:*:*" } + } + }, + { + "category": "product_version", + "name": "3.5.22.40", + "product": { + "name": "Example Control for Linux SL 3.5.22.40", + "product_id": "CSAFPID-52001" + } + } + ] + } + ] + } + ] + } + ] + }, + "vulnerabilities": [ + { + "cve": "CVE-2026-90001", + "title": "Improper input validation in the example runtime", + "notes": [{ "category": "description", "text": "A crafted request can crash the runtime." }], + "product_status": { "known_affected": ["CSAFPID-51001"], "fixed": ["CSAFPID-52001"] }, + "remediations": [ + { "category": "vendor_fix", "details": "Update to version 3.5.22.40.", "url": "https://example.invalid/download", "product_ids": ["CSAFPID-51001"] } + ], + "scores": [ + { "products": ["CSAFPID-51001"], "cvss_v3": { "version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "baseScore": 7.5, "baseSeverity": "HIGH" } } + ] + } + ] +}