From 8adc1e7c644ab089c1e115a68ffbe1a322f66095 Mon Sep 17 00:00:00 2001 From: dajiaohuang Date: Mon, 23 Nov 2026 03:14:52 +0800 Subject: [PATCH] fix: detect exploit references when severities are present get_exploitability_level() used an elif chain, so the exploit-reference branch was only evaluated when an advisory had no severities at all. Almost every advisory carries at least one severity (CVSS, SSVC, EPSS, or a generic textual rating), so a published exploit reference never raised exploitability: advisories with a known exploit were reported as 0.5 (no exploit known) instead of 1. The reference check now runs whenever no exploit record or high EPSS score has already established a higher level, which keeps the existing precedence (exploit records and high EPSS still win) while making published exploit references count. Reported symptom, computed through compute_advisory_risk_score() on an advisory with CVSS 7.5 and EPSS 0.10 plus an exploit reference: before: weighted_severity=6.8 exploitability=0.5 risk_score=3.4 after: weighted_severity=6.8 exploitability=1.0 risk_score=6.8 Signed-off-by: dajiaohuang --- vulnerabilities/risk.py | 2 +- vulnerabilities/tests/test_risk.py | 31 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/vulnerabilities/risk.py b/vulnerabilities/risk.py index b7782ebbc..0b2c9995c 100644 --- a/vulnerabilities/risk.py +++ b/vulnerabilities/risk.py @@ -82,7 +82,7 @@ def get_exploitability_level(exploits, references, severities): exploit_level = 2 break - elif references: + if exploit_level == 0.5 and references: # PoC/Exploit script published for reference in references: if reference.reference_type == VulnerabilityReference.EXPLOIT: diff --git a/vulnerabilities/tests/test_risk.py b/vulnerabilities/tests/test_risk.py index b5c4d4997..bc3e368ca 100644 --- a/vulnerabilities/tests/test_risk.py +++ b/vulnerabilities/tests/test_risk.py @@ -123,6 +123,37 @@ def test_exploitability_level( assert get_exploitability_level(None, None, None) == 0.5 +@pytest.mark.django_db +def test_exploitability_level_with_exploit_reference_and_severities(vulnerability_with_exploit_ref): + """ + A published exploit reference marks the vulnerability as exploitable even + when the vulnerability also carries severities that do not indicate a high + EPSS score. + """ + severities = vulnerability_with_exploit_ref.severities.all() + references = vulnerability_with_exploit_ref.references.all() + + # Severities are present, but none of them is a high EPSS score. + assert list(severities) == [] + + severity = VulnerabilitySeverity.objects.create( + url="https://nvd.nist.gov/vuln/detail/CVE-xxxx-xxxx2", + scoring_system=EPSS.identifier, + value="0.10", + scoring_elements="0.75", + ) + vulnerability_with_exploit_ref.severities.add(severity) + + assert ( + get_exploitability_level( + exploits=None, + references=references, + severities=vulnerability_with_exploit_ref.severities.all(), + ) + == 1 + ) + + @pytest.mark.django_db def test_get_weighted_severity(vulnerability): severities = vulnerability.severities.all()