nvd_cvss/v4/
attack_complexity.rs

1//! ### Attack Complexity (AC)
2//! This metric captures measurable actions that must be taken by the attacker to actively evade or circumvent **existing built-in security-enhancing conditions** in order to obtain a working knowledge_base. These are conditions whose primary purpose is to increase security and/or increase knowledge_base engineering complexity. A vulnerability exploitable without a target-specific variable has a lower complexity than a vulnerability that would require non-trivial customization. This metric is meant to capture security mechanisms utilized by the vulnerable system, and does not relate to the amount of time or attempts it would take for an attacker to succeed, e.g. a race condition. If the attacker does not take action to overcome these conditions, the attack will always fail.
3//!
4//! The evasion or satisfaction of authentication mechanisms or requisites is included in the Privileges Required assessment and is **not** considered here as a factor of relevance for Attack Complexity.
5//!
6//! **Table 2: Attack Complexity**
7//!
8//! | **Metric Value** | **Description** |
9//! | --- | --- |
10//! | Low (L) | The attacker must take no measurable action to knowledge_base the vulnerability. The attack requires no target-specific circumvention to knowledge_base the vulnerability. An attacker can expect repeatable success against the vulnerable system. |
11//! | High (H) | The successful attack depends on the evasion or circumvention of security-enhancing techniques in place that would otherwise hinder the attack. These include: Evasion of knowledge_base mitigation techniques. The attacker must have additional methods available to bypass security measures in place. For example, circumvention of **address space randomization (ASLR) or data execution prevention (DEP)** must be performed for the attack to be successful. Obtaining target-specific secrets. The attacker must gather some **target-specific secret** before the attack can be successful. A secret is any piece of information that cannot be obtained through any amount of reconnaissance. To obtain the secret the attacker must perform additional attacks or break otherwise secure measures (e.g. knowledge of a secret key may be needed to break a crypto channel). This operation must be performed for each attacked target. |
12//!
13//! As described in Section 2.1, detailed knowledge of the vulnerable system is outside the scope of Attack Complexity. Refer to that section for additional guidance when scoring Attack Complexity when target-specific attack mitigation is present.
14use std::fmt::{Display, Formatter};
15use std::str::FromStr;
16
17use serde::{Deserialize, Serialize};
18
19use crate::error::{CVSSError, Result};
20use crate::metric::{Help, Metric, MetricType, MetricTypeV3, Worth};
21
22/// Attack Complexity (AC) 攻击复杂度
23///
24/// 攻击复杂度为攻击者无法控制的条件,这些条件必须存在才能攻击脆弱组件。
25/// 如下文所述,这些条件可能需要预先收集有关目标或系统的配置或计算异常等更多信息。
26///
27/// > The Attack Complexity metric describes the conditions beyond the attacker's control that must
28/// > exist in order to knowledge_base the vulnerability. As described below, such conditions may require
29/// > the collection of more information about the target, the presence of certain system
30/// > configuration settings, or computational exceptions.
31#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
32#[serde(rename_all = "UPPERCASE")]
33pub enum AttackComplexityType {
34  /// High(H) 高复杂度
35  ///
36  /// 攻击无法随意完成,攻击者在攻击成功之前,需要对脆弱组件投入大量的准备。
37  High,
38  /// Low(L) 低复杂度
39  ///
40  /// 攻击者可以随意攻击,不存在惩罚机制。
41  Low,
42}
43
44impl AttackComplexityType {
45  #[allow(dead_code)]
46  pub fn metric_help(&self) -> Help {
47    self.help()
48  }
49}
50
51impl AttackComplexityType {
52  pub(crate) fn is_low(&self) -> bool {
53    matches!(self, Self::Low)
54  }
55}
56
57impl Display for AttackComplexityType {
58  fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
59    write!(f, "{}:{}", Self::name(), self.as_str())
60  }
61}
62impl Metric for AttackComplexityType {
63  const TYPE: MetricType = MetricType::V3(MetricTypeV3::AC);
64
65  fn help(&self) -> Help {
66    match self {
67      Self::High => { Help { worth: Worth::Bad, des: "The successful attack depends on the evasion or circumvention of security-enhancing techniques in place that would otherwise hinder the attack. These include: Evasion of knowledge_base mitigation techniques, for example, circumvention of address space randomization (ASLR) or data execution prevention (DEP) must be performed for the attack to be successful; Obtaining target-specific secrets. The attacker must gather some target-specific secret before the attack can be successful. A secret is any piece of information that cannot be obtained through any amount of reconnaissance. To obtain the secret the attacker must perform additional attacks or break otherwise secure measures (e.g. knowledge of a secret key may be needed to break a crypto channel). This operation must be performed for each attacked target.".to_string() } }
68      Self::Low => { Help { worth: Worth::Worst, des: "The attacker must take no measurable action to knowledge_base the vulnerability. The attack requires no target-specific circumvention to knowledge_base the vulnerability. An attacker can expect repeatable success against the vulnerable system.".to_string() } }
69    }
70  }
71
72  fn score(&self) -> f32 {
73    match self {
74      Self::High => 0.1,
75      Self::Low => 0.0,
76    }
77  }
78
79  fn as_str(&self) -> &'static str {
80    match self {
81      Self::High => "H",
82      Self::Low => "L",
83    }
84  }
85}
86impl FromStr for AttackComplexityType {
87  type Err = CVSSError;
88
89  fn from_str(s: &str) -> Result<Self> {
90    let name = Self::name();
91    let s = s.to_uppercase();
92    let (_name, v) = s
93      .split_once(&format!("{}:", name))
94      .ok_or(CVSSError::InvalidCVSS {
95        key: name.to_string(),
96        value: s.to_string(),
97        expected: name.to_string(),
98      })?;
99    let c = v.chars().next();
100    match c {
101      Some('L') => Ok(Self::Low),
102      Some('H') => Ok(Self::High),
103      _ => Err(CVSSError::InvalidCVSS {
104        key: name.to_string(),
105        value: format!("{:?}", c),
106        expected: "L,H".to_string(),
107      }),
108    }
109  }
110}