Repository navigation
fix: false legal citations and false vulnerability verdicts (law #103 port, not-affected citations, CPE case, platform/edition conditions, KEV by CPE) - #89
Merged
Conversation
…tches, read-only cache law_fetcher.py and law_cache.py were mailradar's copies from before maksimtech/mailradar#103, apart from PATCHRADAR_HOME. They are now its copies after it (commit e649dea), with the same variable kept, and law_checker.py and the scan's status lines take the same changes. - A citation was "verified" per act: download success plus the article being found. With article 32 in Cellar's page and paragraph 2 missing from what was parsed, GDPR art. 32(2) for a critical CVE fell back to the cache, old SHA-256 and date included, under "verified against Cellar", or stood beside "SHA256: not available". Each cited reference is now looked up in the text just parsed; a missing one is a fetch failure (law_checker.check). - Only httpx.HTTPError was a fetch failure: a redirect to http://xn--/DOC_1 raised idna.core.IDNAError out of the whole law check. httpx.InvalidURL and ValueError are fetch failures too. - Redirects stay on the source's host (publications.europa.eu, eur-lex.europa.eu, www.normattiva.it), default port only. - A body is streamed and refused past 32 MiB; a fetch ends after 120 s. - With a read-only cache a changed law text was cited without the warning and an unchanged one was dated to today: law_cache.merge now runs before the save, whatever the save does. - LawFetchError carries source and reached; ActStatus carries tried, failure and reason, and `scan` prints "Cellar answered without the text cited" or "Cellar and EUR-Lex unreachable" instead of "EUR-Lex unreachable". - A deeply nested law_cache.json is an empty cache, not a RecursionError; Normattiva's -bis/-ter/... paragraphs can be cited. The tests are mailradar's, adapted: the end-to-end ones answer Cellar with the recorded GDPR page, or a page derived from it without the ELI id of paragraph 32(2), through httpx.MockTransport. Each was seen failing before the port. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`scan` handed every CVE found by name to the law check, whatever its verdict. For 7-Zip 26.06 it printed "not affecting it: 2" and then cited CVE-2025-0411 (fixed in 24.09) and CVE-2026-14266 (fixed in 26.02) under GDPR art. 25 and art. 32 (bug hunt, scan_7zip_2606.txt); a critical unpatched one would have reached D.Lgs. 138/2024 art. 24 as well. _scan_target now hands the law check only the CVEs that affect the installed version, could not be evaluated, or belong to an entry matched by name. The API runs no law check (docs/nis2-compliance.md: the law sources are contacted by `scan` from the command line only), so it has nothing to change. The test answers NVD with its recorded record of CVE-2025-0411 (tests/fixtures/nvd_cve_2025_0411_recorded.json) and scans 7-Zip 26.06 (not cited) and 24.08 (still cited). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
parse_cpe accepted `cpe:2.3:a:Mozilla:Thunderbird` as typed, from `add --cpe`
and from POST /api/watchlist/{name}?cpe= alike, and affected.ranges_in compared
its vendor and product with NVD's lower-case cpeMatch names as strings
(fields[3] != vendor). Nothing matched, so every CVE of the program was judged
"not affected" and left out of the table: a false all-clear made of a capital
letter.
CPE 2.3 names match without regard to case, and NVD writes them in lower case.
parse_cpe now returns the name in lower case, so both routes store it as NVD
writes it, and ranges_in compares vendor and product case-insensitively, which
also covers entries stored before this change (WatchEntry re-parses them).
Tests: parse_cpe, the CLI and the API store the lower-case form; the verdict on
NVD's recorded CVE-2025-0411 is "affected, fixed in 24.09" for 7-Zip 24.08
whatever case vendor and product are given in. Each failed first.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…te or edition ranges_in read the version of each vulnerable cpeMatch entry and nothing else: neither the CPE fields after the version (update, sw_edition, ...) nor the AND configuration the entry sits in. On NVD's records, recorded on 2026-11-17 for the bug hunt: - CVE-2026-16424 is Chrome < 150.0.7871.182 AND (vulnerable: false) Android: Chrome 150.0.7871.100 on Windows was "affected"; CVE-2026-17709, the same with macOS, likewise for 151.0.7922.10; - CVE-2024-9680 has Firefox sw_edition esr < 115.16.1 beside sw_edition - < 131.0.2: ESR 115.17.0 was "affected, fix in 131.0.2"; - CVE-2007-4725 lists `7-zip:4.43:beta` ... `4.52:beta`: the final 4.43 was "affected" (and python:3.12.0:rc1 would make 3.12.0 final affected). The watchlist knows the version and the CPE, not the operating system. A range now carries `conditions`: the products the other nodes of an AND configuration require ("on Android", "with telco cloud platform"), and every field after the version that the watched CPE does not name ("for update beta", "for the esr edition"). A range with conditions that contains the version makes the CVE "not evaluable", the reason naming the condition, never "affected"; outside the range it is still "not affected". Where the watched CPE names the field (cpe:2.3:a:mozilla:firefox:*:*:*:*:esr:*:*:*) the entries with another value are left out and the matching ones decide alone. A `-` is a condition only where the record names the product with another value in that field too, so VS Code's lone `target_sw: -` (CVE-2026-81376) stays an unconditional range. judge and mark take the watched Cpe, which now keeps its fields; the CLI and the API pass it. affects() no longer counts a conditional range as a hit. Tests: tests/test_affected_conditions.py, on the recorded records, through judge, the CLI scan and the API scan; each failed first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The KEV collector matched the watchlist name against CISA's vendorProject and product only. CISA files Chrome as "Google / Chromium V8", "Chromium Mojo", "Chromium" and so on: on the 2026-11-17 catalogue (1782 entries) the word "chrome" was in 6 of the 72 exploited Chrome CVEs, and a scan reported the other 66 as not known to be exploited. For an entry with a CPE, kev.fetch_cves now also asks NVD, once and paged, for the CVEs it flags as in KEV for that product (nvd.known_exploited_for: hasKev + virtualMatchString=cpe:2.3:<part>:<vendor>:<product>) and takes those catalogue entries whatever CISA called the product. Measured the same day, NVD returned the 72 and six more Chrome CVEs whose CISA entry names no browser (Adobe Flash Player, WebRTC, Google Skia, Google Dawn). NVD's records come back too, ahead of CISA's, so the merged rows carry NVD's configurations and the scan judges them without a cveId lookup each. A real scan of Chrome 150.0.7871.100 in an isolated HOME found 78 exploited CVEs (6 before) with no per-id request. Chosen over an alias table (chrome -> Chromium, Chromium V8, ...): that would fix one product and need upkeep for every other one CISA names by a component (Win32k, Exchange Server, ...), while the CPE is the name NVD has already mapped every KEV CVE to. Entries without a CPE keep the keyword match. If NVD cannot be asked, the keyword's matches stand as `partial` and the scan says it is incomplete. The CLI and the API pass the entry's CPE; docs/nis2-compliance.md lists the new query, and test_nis2_evidence.py holds it to the code. Tests (tests/test_kev_by_cpe.py) answer from excerpts of the real catalogue and of NVD's real hasKev answer for google:chrome, both declared `_derived`; the CLI scan found 1 CVE before the fix and 5 after. test_judge_through_nvd.py routes the new request explicitly instead of letting it fall into its 503. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Merging this PR will not alter performance1 warning
Comparing |
|
maksimtech
added a commit
that referenced
this pull request
Nov 18, 2026
The bug hunt of 2026-11-17 and its fixes (#89, #91), the law check carrying mailradar#103, the OpenSSL exceptions of 2026-11-10 and the upkeep since 2026.48 ship as 2026.49. RELEASING.md wants the section in place before the bump; [Unreleased] stays, empty, above it. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.



Five defects from the bug hunt of 2026-11-17 that made PatchRadar state something false: a legal citation the scan itself contradicted, or a vulnerability verdict NVD does not support. One commit each; every fix has a test that was seen failing first, on recorded NVD, KEV and Cellar answers (or excerpts of them, declared
_derived).1. Law check: port of maksimtech/mailradar#103 (
fix(law))law_fetcher.pyandlaw_cache.pyare mailradar's post-#103 copies (onlyPATCHRADAR_HOMEand names differ);law_checker.checkverifies each cited reference, merges withlaw_cache.mergebefore saving, andActStatusgainstried/failure/reason, whichscanprints.test_law_fetcher.py,test_law_cache.py,test_law_sources.py,test_law_checker.py(Cellar answered at the HTTP boundary with the recorded GDPR page, or a page derived from it without paragraph 32(2)),test_law_unverifiable.py.2. The law check cited CVEs the same scan judged "not affected" (
fix(cli))_hunt/scan_7zip_2606.txt)._scan_targethands the law check every CVE except those judged "not affected". The API runs no law check, so nothing to change there.test_cli_law.py, on NVD's recorded record of CVE-2025-0411: not cited for 26.06, still cited for 24.08.3. A CPE with capitals made every CVE "not affected" (
fix(cpe))cpe:2.3:a:Mozilla:Thunderbirdwas accepted and compared with NVD's lower-case names as strings: nothing matched, every CVE was "not affected" and hidden — a false all-clear.parse_cpereturns the name in lower case (CLIaddand the API store it so);ranges_incompares vendor and product case-insensitively (covers rows stored before).test_cpe.py,test_watchlist_versions.py,test_api_versioned.py,test_affected_verdict.py.4. Verdicts ignored the CPE fields after the version and the AND configurations (
fix(affected))7-zip:4.43:betaentries.conditions— the products the other nodes of an AND configuration require, and every field after the version the watched CPE does not name. A conditional range containing the version gives not evaluable, with the condition in the reason ("NVD lists it as affecting 150.0.7871.100 only on Android, which the watchlist does not record"), never "affected". A watched CPE that names the field (cpe:2.3:a:mozilla:firefox:*:*:*:*:esr:*:*:*) selects those entries and drops the others. A-counts as a condition only where the record also names the product with another value in that field (VS Code's lonetarget_sw: -is unchanged). CLI and API pass the watched CPE tomark.test_affected_conditions.py—judgeon the recorded records, the CLI scan and the API scan.5. KEV: "chrome" matched 6 of the 72 exploited Chrome CVEs (
fix(kev))hasKev+virtualMatchString=cpe:2.3:<part>:<vendor>:<product>, paged) and takes those catalogue entries whatever CISA called the product; NVD's records come along, so they are judged without acveIdlookup each. Measured on 2026-11-17: NVD returned all 72, plus 6 Chrome CVEs whose CISA entry names no browser (Flash Player, WebRTC, Skia, Dawn). An alias table would fix Chrome only and need upkeep for every product CISA names by a component. Entries without a CPE keep the keyword match; if NVD fails, the keyword's matches stand and the scan says it is incomplete.docs/nis2-compliance.mdlists the new query (held bytest_nis2_evidence.py).test_kev_by_cpe.pyon an excerpt of the real 2026.11.17 catalogue and of NVD's real hasKev answer: collector, NVD failure, CLI scan, API scan.A real run (isolated HOME) of
scan chromefor 150.0.7871.100 with--cpe cpe:2.3:a:Google:Chromefound 78 exploited CVEs (6 before), judged with no per-id lookup.Not in this PR (found, out of scope)
_NUMERICorders a pre-release written2.0bafter 2.0 (_hunt/tests/test_hunt_affected.py::test_prerelease_letter_suffix_orders_after_the_release).AI disclosure
Written by Claude Code (Claude Opus 5.5) from the bug-hunt evidence. Each fix was checked against the code by a test that failed before it and passes after; the full suite,
ruff checkandmypypass locally.🤖 Generated with Claude Code