Skip to content

fix: use detected version for CVE lookup filtering - #29

Merged
HC-ONLINE merged 1 commit into
mainfrom
feature/cve-version-filter
Jul 31, 2026
Merged

fix: use detected version for CVE lookup filtering#29
HC-ONLINE merged 1 commit into
mainfrom
feature/cve-version-filter

Conversation

@HC-ONLINE

Copy link
Copy Markdown
Owner

Description

Fix CVE lookup to use the detected technology version instead of searching generically by product name only.

Problem

Previously, when fingerprinting detected a technology like jQuery 3.6.0, the CVE lookup would search for jQuery without the version, returning all CVEs for that product regardless of whether they affected the detected version. This caused noise and false positives.

Changes

1. AffectedProduct.matches_version() — Version range support

  • File: src/ciberwebscan/core/analyzers/cve/models.py
  • Replaced simple exact-match with full version range support
  • Uses packaging.version.Version for semantic version comparison
  • Handles versionStartIncluding and versionEndExcluding from CPE configurations
  • Gracefully handles unparseable versions (assumes affected)

2. _lookup_cves() — Version-aware filtering

  • File: src/ciberwebscan/services/analyze_service.py
  • Now passes tech.version to the CVE aggregator
  • Added _cve_affects_version() to post-filter CVEs by detected version
  • Added deduplication of CVE entries across technologies

3. Dependency

  • File: pyproject.toml
  • Added packaging>=21.0 for semantic version parsing

Flow

BEFORE: 'jQuery 3.6.0' → searches 'jQuery' → returns ALL CVEs (noise)
AFTER: 'jQuery 3.6.0' → searches 'jQuery' + '3.6.0' → filters → only relevant CVEs

API Compatibility

All three CVE sources are supported:

  • NVD: Uses CPE wildcard, filtering happens post-fetch via _cve_affects_version()
  • CIRCL: Passes vendor/product, parses ranges from CPE configs
  • Vulners: Sends version directly in the request

Testing

  • All 1180 unit tests pass (no regressions)

Breaking Changes

None. This is a backward-compatible improvement.

- Improve AffectedProduct.matches_version() to support version ranges
  (versionStartIncluding/versionEndExcluding) using packaging.version
- Pass detected version to CVE aggregator in _lookup_cves()
- Add _cve_affects_version() to filter CVEs by detected version
- Add deduplication of CVE entries across technologies
- Add packaging dependency for semantic version comparison

Previously, fingerprinting detected 'jQuery 3.6.0' but CVE lookup
searched for 'jQuery' generically, returning all CVEs regardless of
version. Now CVEs are filtered to only those affecting the detected
version.
@HC-ONLINE
HC-ONLINE merged commit 81505b8 into main Jul 31, 2026
3 checks passed
@HC-ONLINE
HC-ONLINE deleted the feature/cve-version-filter branch July 31, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant