Repository navigation
Description
In ApacheTomcatImporterPipeline, single hyphenated Tomcat milestone and release-candidate versions in Affects: lines (such as 11.0.0-M5 in CVE-2023-34981, 11.0.0-M1 in CVE-2023-24998, and 8.0.0-RC1 in CVE-2013-4286) are split on "-" as A-B ranges, producing vers: union ranges that exclude the affected pre-release and match stable releases (>= 11.0.1 or >= 8.0.1) instead.
Reproduction
Using the CVE-2023-34981 entry from https://tomcat.apache.org/security-11.html (the same output occurs when running ApacheTomcatImporterPipeline directly against security-11.html and security-8.html):
DJANGO_SETTINGS_MODULE=vulnerablecode.settings SECRET_KEY=test ALTCHA_HMAC_KEY=test python - << 'EOF'
import types
from unittest.mock import patch
import django
django.setup()
from univers.versions import MavenVersion, SemverVersion
from vulnerabilities.pipelines.v2_importers.apache_tomcat_importer import ApacheTomcatImporterPipeline
HTML = """
<h3 id="Fixed_in_Apache_Tomcat_11.0.0-M6"><span class="pull-right">2023-05-09</span> Fixed in Apache Tomcat 11.0.0-M6</h3>
<div class="text">
<p><strong>Important: Information disclosure</strong>
<a href="/?url=http%3A%2F%2Fcve.mitre.org%2Fcgi-bin%2Fcvename.cgi%3Fname%3DCVE-2023-34981" rel="nofollow">CVE-2023-34981</a></p>
<p>Affects: 11.0.0-M5</p>
</div>
"""
with patch("vulnerabilities.pipelines.v2_importers.apache_tomcat_importer.requests.get") as mock_get:
mock_get.return_value.content = HTML.encode("utf-8")
pipeline = ApacheTomcatImporterPipeline()
pipeline.fetch_advisory_links = types.MethodType(
lambda self: ["https://tomcat.apache.org/security-11.html"], pipeline
)
advisory = list(pipeline.collect_advisories())[0]
for pkg in advisory.affected_packages:
rng = pkg.affected_version_range
vcls = MavenVersion if pkg.package.type == "maven" else SemverVersion
print(f"{pkg.package} -> {rng}")
print(f" 11.0.0-M5 in range: {vcls('11.0.0-M5') in rng}")
print(f" 11.0.2 in range: {vcls('11.0.2') in rng}")
EOFActual output
INFO ... Processing 1 advisories from https://tomcat.apache.org/security-11.html
INFO ... Processing advisory CVE-2023-34981
INFO ... 'M5' is not a valid SemverVersion InvalidVersion("'M5' is not a valid <class 'univers.versions.SemverVersion'>")
pkg:apache/tomcat -> vers:apache/!=11.0.0|>=11.0.0
11.0.0-M5 in range: False
11.0.2 in range: True
pkg:maven/org.apache.tomcat/tomcat -> vers:maven/<=M5|!=11.0.0|>=11.0.0
11.0.0-M5 in range: False
11.0.2 in range: True
Expected behavior
11.0.0-M5 should be parsed as a single exact version (=11.0.0-M5) rather than split on "-" into >=11.0.0 and <=M5, so 11.0.0-M5 in range is True and stable releases such as 11.0.2 evaluate to False.
Versions tested
- Latest release:
v40.2.0(910df628cf485e8d58c61b0a7c8c1a64b0964a14) main:9a9c9b3e8ff7d173bf8d2d04b4587c445a6d96b3- Environment: Python 3.11.2,
univers==32.0.1, Linux x86_64
Root cause
In vulnerabilities/pipelines/v2_importers/apache_tomcat_importer.py, both to_version_ranges_apache (line 140) and to_version_ranges_maven (line 210) treat any version_item containing "-" (when "to" is absent) as a two-endpoint range (intended for older 7.0.0-7.0.53 entries), which splits 11.0.0-M5 into >=11.0.0 and <=M5 (also producing the 'M5', 'M1', and 'RC1' SemverVersion log errors noted in #1555 while silently corrupting the MavenVersionRange).
Found with a differential-testing tool; the report was drafted with AI assistance and reviewed and edited by me.
Credit: https://ucsbplse.github.io/
Activity
nikolya-ctrl commentedon Nov 25, 2026
Hey! I'd like to take this one if no one else is on it.
If I've got it right, both
to_version_ranges_apacheandto_version_ranges_mavensee the-in something like11.0.0-M5and treat it as a range, so it ends up as>=11.0.0and<=M5instead of just one version.My plan is to only treat it as a range when both sides are real version numbers (like
7.0.0-7.0.53), and otherwise keep it as a single version (11.0.0-M5,8.0.0-RC1). I'll fix it in both functions and add tests for both cases so the normal ranges don't break.I'll reproduce it locally first with your script. Does this sound like the right approach? Happy to hear any tips!
Treat single Tomcat pre-release versions as exact versions