Repository navigation
fix: detect exploit references when severities are present - #2519
Open
dajiaohuang wants to merge 1 commit into
Open
dajiaohuang wants to merge 1 commit into
dajiaohuang wants to merge 1 commit into
Conversation
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 <mikewushuwen@outlook.com>
dajiaohuang
marked this pull request as ready for review
November 23, 2026 04:15
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The defect
vulnerabilities/risk.py,get_exploitability_level()(line 85 before this change).The function decides exploitability in three steps, written as an
if/elif/elifchain:Because the reference branch is an
elif, it is only ever reached when an advisory has no severities at all. Almost every advisory carries at least one severity — CVSS, SSVC, EPSS, or a generic textual rating — so in practice thereferencesbranch is dead code and a published exploit reference never raises exploitability.A vulnerability with a published exploit is therefore reported as
0.5("no exploit known") rather than1.Path
Public entry point → call chain → state → consumer:
reference_type="exploit"(vulnerabilities/pipes/osv_v2.py,vulnerabilities/pipelines/v2_importers/vulnrichment_importer.py, and the ExploitDB improver). Real data carries these:vulnerabilities/tests/test_data/vulnrichment/vulnrichment-data3-expected.jsoncontains a reference with"reference_type": "exploit".insert_advisory_v2()→vulnerabilities/pipes/advisory.py:366, which computes risk at import time.compute_advisory_risk_score()(vulnerabilities/pipes/risk_score.py:89) passes those references and severities tocompute_vulnerability_risk_factors()→get_exploitability_level().AdvisoryV2.exploitability/risk_scoreand surfaced to users in API v2/v3 (exploitability,risk_score) and in the advisory detail, vulnerability detail and package detail pages.The v2 improver
vulnerabilities/pipelines/v2_improvers/compute_package_risk.py:100reaches the same helper the same way.The wrong result
Computed through
compute_advisory_risk_score()against realAdvisoryV2rows in the test database — an advisory with CVSS 7.5 and EPSS 0.10 (below the 0.8 threshold) plus a published exploit reference:The advisory with a known exploit is indistinguishable from one with none, and its risk score is understated by half.
The proof
Same command, same input, base versus branch. The regression test is
test_exploitability_level_with_exploit_reference_and_severitiesinvulnerabilities/tests/test_risk.py.On
main(git stash-ed change, i.e. pristinerisk.py):With this branch:
The same advisory through
compute_advisory_risk_score(), before and after:The change
One line in
get_exploitability_level(): the reference branch becomes a separateifguarded byexploit_level == 0.5, instead of anelifonseverities.Existing precedence is preserved exactly — exploit records still yield
2, and a high EPSS score still yields2and still wins over a bare exploit reference. The reference check only runs when nothing stronger has been found.The regression test adds an EPSS severity (0.10, below the threshold) to a vulnerability that already has an exploit reference, and asserts exploitability is
1.The pre-existing test only passed because its subject had no severities at all, which is why this went unnoticed.
What I validated
vulnerabilities/tests/test_risk.py— 5 passed.vulnerabilities/tests/pipelines/test_compute_package_risk.pyandvulnerabilities/tests/pipelines/v2_improvers/test_compute_package_risk_v2.py— passed, 7 total with the above.vulnerabilities/tests/pipelines/v2_improversas a package — 63 passed, 4 failed.What I did not validate
mainand environmental: they need PostgreSQLDISTINCT ON, which SQLite does not support. I re-ran that package with my changes stashed and got the identical 4 failures. They are not related to this change.--no-migrations, because the migration chain itself usesDISTINCT ON. I did not run against PostgreSQL.make checkis commented out in CI).python -m pytestfor the risk modules andmake testare the project's own commands; I ran the former at file/package scope only.AdvisoryV2,AdvisorySeverityandAdvisoryReferencerows composed the way the importer composes them.Note on scope
This change is deliberately limited to the reachability bug. It does not reconsider the EPSS 0.8 threshold, the weighting of EPSS into
weighted_severity, or the separate open questions in #2371 and #2472 about how EPSS is modelled.