Every CVESearch/Get API key

CVE-2026-140095

python-semver: super-quadratic ReDoS in _LAST_NUMBER via attacker-controlled version strings

Explain with AI
ChatGPTClaudeGoogle AI
Severity
8.7High
Network attack, no privileges, no user interactionCVSS 4.0, CVE List
Exploitation
None reported
1 exploit-related link
Exploit chance
0.86% in 30 days
Percentile59th
EPSS, scored
Listed fix
3.1.3 for semver
From GitHub Advisories and OSV34 other affected packages

Overview

python-semver is a Python package for working with Semantic Versioning. Prior to 3.1.3, semver.Version.parse accepted an arbitrarily long alphabetic BUILD_IDENTIFIER and bump_build passed it through _increment_string to Version._LAST_NUMBER in src/semver/version.py. The expression contained ambiguous repeated non-digit quantifiers around a required digit run, causing super-quadratic backtracking when no digit was present and allowing an attacker-controlled valid version string to monopolize the Python process and deny service. This issue is fixed in version 3.1.3.

CVSS 4.0 vector

Exploitability

Attack vector
Network
Complexity
Low
Attack requirements
None
Privileges needed
None
User interaction
None

Impact on the vulnerable system

Confidentiality
None
Integrity
None
Availability
High

Impact on subsequent systems

Confidentiality
None
Integrity
None
Availability
None
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N

Exploit chance over time

Up 0.3 points since Dec 1, 2026
EPSS score, scored every day from Dec 1, 2026 to Dec 4, 2026: lowest 0.58% on Dec 1, 2026, highest 0.86% on Dec 2, 2026, 0.86% on the last day.

Affected

Packages 35

Affected packages
PackageAffectedFixed
semver
PyPI
through 3.1.2
3.1.3
before 3.1.3, plus listed versions
0.0.10.0.22.0.02.0.12.0.2
Show 45 more versionsShow less
2.1.02.1.12.1.22.10.02.10.12.10.22.11.02.12.02.13.02.2.02.2.12.3.02.3.12.4.02.4.12.4.22.5.02.6.02.7.02.7.12.7.22.7.32.7.42.7.52.7.62.7.72.7.82.7.92.8.02.8.12.9.02.9.13.0.03.0.0.dev13.0.0.dev23.0.0.dev33.0.0.dev43.0.0rc13.0.13.0.23.0.33.0.43.1.03.1.13.1.2
3.1.3
python-semver
Debian:12
All versions, plus listed versions
2.10.2-33.0.2-13.0.2-23.0.2-3
None listed
python-semver
Debian:13
All versions, plus listed versions
3.0.2-13.0.2-23.0.2-3
None listed
python-semver
Debian:14
All versions, plus listed versions
3.0.2-13.0.2-23.0.2-3
None listed
azure-cli
Docker Hardened Images:Alpine:3.23
2.88.0-r0 and later, plus listed versions
2.89.1-r02.89.1-r12.90.0-r02.90.0-r12.90.0-r2
Show 7 more versionsShow less
2.91.0-r02.91.0-r12.91.0-r22.91.0-r32.92.0-r02.93.0-r02.94.0-r0
None listed
azure-cli
Docker Hardened Images:Alpine:3.24
2.88.0-r0 and later, plus listed versions
2.89.1-r02.89.1-r12.90.0-r02.90.0-r12.90.0-r2
Show 7 more versionsShow less
2.91.0-r02.91.0-r12.91.0-r22.91.0-r32.92.0-r02.93.0-r02.94.0-r0
None listed
datadog-agent-jmxfetch-7
Docker Hardened Images:Alpine:3.23
0.52.0-r0 and later, plus listed versions
0.52.0-r10.52.0-r20.52.0-r30.52.0-r40.52.0-r50.52.0-r60.52.0-r70.52.0-r8
None listed
datadog-agent-jmxfetch-7
Docker Hardened Images:Alpine:3.24
0.52.0-r0 and later, plus listed versions
0.52.0-r10.52.0-r20.52.0-r30.52.0-r40.52.0-r50.52.0-r60.52.0-r70.52.0-r8
None listed
localstack
Docker Hardened Images:Alpine:3.23
4.14.0-r0 and later, plus listed versions
4.14.0-r14.14.0-r104.14.0-r114.14.0-r124.14.0-r13
Show 11 more versionsShow less
4.14.0-r144.14.0-r154.14.0-r164.14.0-r24.14.0-r34.14.0-r44.14.0-r54.14.0-r64.14.0-r74.14.0-r84.14.0-r9
None listed
Show 26 more packagesShow less
Affected packages
PackageAffectedFixed
localstack
Docker Hardened Images:Alpine:3.24
4.14.0-r0 and later, plus listed versions
4.14.0-r14.14.0-r104.14.0-r114.14.0-r124.14.0-r13
Show 11 more versionsShow less
4.14.0-r144.14.0-r154.14.0-r164.14.0-r24.14.0-r34.14.0-r44.14.0-r54.14.0-r64.14.0-r74.14.0-r84.14.0-r9
None listed
prefect-3
Docker Hardened Images:Alpine:3.23
3.9.1-r0 and later, plus listed versions
3.9.2-r03.9.2-r13.9.3-r03.9.3-r13.9.3-r2
Show 6 more versionsShow less
3.9.4-r03.9.5-r03.9.6-r03.9.6-r13.9.6-r23.9.6-r3
None listed
prefect-3
Docker Hardened Images:Alpine:3.24
3.9.1-r0 and later, plus listed versions
3.9.2-r03.9.2-r13.9.3-r03.9.3-r13.9.3-r2
Show 6 more versionsShow less
3.9.4-r03.9.5-r03.9.6-r03.9.6-r13.9.6-r23.9.6-r3
None listed
azure-cli
Docker Hardened Images:Debian:13
2.88.0-0 and later, plus listed versions
2.89.1-02.89.1-12.90.0-02.90.0-12.90.0-2
Show 11 more versionsShow less
2.90.0-32.90.0-42.90.0-52.91.0-02.91.0-12.91.0-22.91.0-32.92.0-02.93.0-02.93.0-12.94.0-0
None listed
datadog-agent-core-7-fips
Docker Hardened Images:Debian:13
7.85.1-0 and later, plus listed versions
7.85.2-07.85.2-17.85.3-07.85.4-07.85.4-1
Show 14 more versionsShow less
7.85.4-107.85.4-117.85.4-27.85.4-37.85.4-47.85.4-57.85.4-67.85.4-77.85.4-87.85.4-97.85.5-07.86.0-07.86.0-17.86.0-2
None listed
datadog-agent-core-7
Docker Hardened Images:Debian:13
7.85.1-0 and later, plus listed versions
7.85.2-07.85.2-17.85.3-07.85.4-07.85.4-1
Show 14 more versionsShow less
7.85.4-107.85.4-117.85.4-27.85.4-37.85.4-47.85.4-57.85.4-67.85.4-77.85.4-87.85.4-97.85.5-07.86.0-07.86.0-17.86.0-2
None listed
datadog-agent-dev
Docker Hardened Images:Debian:13
7.80.2-0 and later, plus listed versions
7.80.2-17.80.2-107.80.2-117.80.2-127.80.2-13
Show 39 more versionsShow less
7.80.2-147.80.2-157.80.2-27.80.2-37.80.2-47.80.2-57.80.2-67.80.2-77.80.2-87.80.2-97.84.4-07.84.6-07.84.6-17.84.6-27.85.0-07.85.1-07.85.1-17.85.2-07.85.2-17.85.2-27.85.3-07.85.4-07.85.4-17.85.4-107.85.4-117.85.4-127.85.4-27.85.4-37.85.4-47.85.4-57.85.4-67.85.4-77.85.4-87.85.4-97.85.5-07.86.0-07.86.0-17.86.0-27.86.0-3
None listed
datadog-agent-fips-dev
Docker Hardened Images:Debian:13
7.80.2-0 and later, plus listed versions
7.80.2-17.80.2-107.80.2-117.80.2-127.80.2-13
Show 38 more versionsShow less
7.80.2-147.80.2-27.80.2-37.80.2-47.80.2-57.80.2-67.80.2-77.80.2-87.80.2-97.84.4-07.84.6-07.84.6-17.84.6-27.85.0-07.85.1-07.85.1-17.85.2-07.85.2-17.85.2-27.85.3-07.85.4-07.85.4-17.85.4-107.85.4-117.85.4-127.85.4-27.85.4-37.85.4-47.85.4-57.85.4-67.85.4-77.85.4-87.85.4-97.85.5-07.86.0-07.86.0-17.86.0-27.86.0-3
None listed
datadog-agent-fips
Docker Hardened Images:Debian:13
7.80.2-0 and later, plus listed versions
7.80.2-17.80.2-107.80.2-117.80.2-127.80.2-13
Show 38 more versionsShow less
7.80.2-147.80.2-27.80.2-37.80.2-47.80.2-57.80.2-67.80.2-77.80.2-87.80.2-97.84.4-07.84.6-07.84.6-17.84.6-27.85.0-07.85.1-07.85.1-17.85.2-07.85.2-17.85.2-27.85.3-07.85.4-07.85.4-17.85.4-107.85.4-117.85.4-127.85.4-27.85.4-37.85.4-47.85.4-57.85.4-67.85.4-77.85.4-87.85.4-97.85.5-07.86.0-07.86.0-17.86.0-27.86.0-3
None listed
datadog-agent-integrations-7
Docker Hardened Images:Debian:13
7.85.1-0 and later, plus listed versions
7.85.1-17.85.2-07.85.2-17.85.3-07.85.4-0
Show 15 more versionsShow less
7.85.4-17.85.4-27.85.4-37.85.4-47.85.5-07.86.0-07.86.0-17.86.0-27.86.0-37.86.0-47.86.0-57.86.0-67.86.0-77.86.0-87.86.0-9
None listed
datadog-agent-jmxfetch-7
Docker Hardened Images:Debian:13
0.52.0-0 and later, plus listed versions
0.52.0-10.52.0-20.52.0-30.52.0-40.52.0-50.52.0-60.52.0-70.52.0-8
None listed
datadog-agent-process-7-fips
Docker Hardened Images:Debian:13
7.85.1-0 and later, plus listed versions
7.85.2-07.85.2-17.85.3-07.85.4-07.85.4-1
Show 14 more versionsShow less
7.85.4-107.85.4-117.85.4-27.85.4-37.85.4-47.85.4-57.85.4-67.85.4-77.85.4-87.85.4-97.85.5-07.86.0-07.86.0-17.86.0-2
None listed
datadog-agent-process-7
Docker Hardened Images:Debian:13
7.85.1-0 and later, plus listed versions
7.85.2-07.85.2-17.85.3-07.85.4-07.85.4-1
Show 14 more versionsShow less
7.85.4-107.85.4-117.85.4-27.85.4-37.85.4-47.85.4-57.85.4-67.85.4-77.85.4-87.85.4-97.85.5-07.86.0-07.86.0-17.86.0-2
None listed
datadog-agent
Docker Hardened Images:Debian:13
7.80.2-0 and later, plus listed versions
7.80.2-17.80.2-107.80.2-117.80.2-127.80.2-13
Show 39 more versionsShow less
7.80.2-147.80.2-157.80.2-27.80.2-37.80.2-47.80.2-57.80.2-67.80.2-77.80.2-87.80.2-97.84.4-07.84.6-07.84.6-17.84.6-27.85.0-07.85.1-07.85.1-17.85.2-07.85.2-17.85.2-27.85.3-07.85.4-07.85.4-17.85.4-107.85.4-117.85.4-127.85.4-27.85.4-37.85.4-47.85.4-57.85.4-67.85.4-77.85.4-87.85.4-97.85.5-07.86.0-07.86.0-17.86.0-27.86.0-3
None listed
litellm-database-1.110
Docker Hardened Images:Debian:13
1.110.0-0 and later, plus listed versions
1.110.1-01.110.2-01.110.2-11.110.3-01.110.3-1
Show 7 more versionsShow less
1.110.4-01.110.4-11.110.4-21.110.4-31.110.4-41.110.4-51.110.4-6
None listed
litellm
Docker Hardened Images:Debian:13
1.95.0-0 and later, plus listed versions
1.100.0-01.100.1-01.101.0-01.101.0-11.102.0-0
Show 45 more versionsShow less
1.103.0-01.103.0-11.103.2-01.103.3-01.104.1-01.104.2-01.104.3-01.105.1-01.106.0-01.106.0-11.106.0-21.106.0-31.106.0-41.106.0-51.106.0-61.106.0-71.106.0-81.106.0-91.108.0-01.108.0-11.108.1-01.108.1-11.108.3-01.108.3-11.108.4-01.108.4-11.108.4-21.109.0-01.109.1-01.109.1-11.110.0-01.110.0-11.110.1-01.110.2-01.110.2-11.110.2-21.110.3-01.110.3-11.111.0-01.111.1-01.112.0-01.112.0-11.112.1-01.112.1-11.112.2-0
None listed
localstack
Docker Hardened Images:Debian:13
4.14.0-0 and later, plus listed versions
4.14.0-14.14.0-104.14.0-114.14.0-124.14.0-13
Show 16 more versionsShow less
4.14.0-144.14.0-154.14.0-164.14.0-174.14.0-184.14.0-194.14.0-24.14.0-204.14.0-214.14.0-34.14.0-44.14.0-54.14.0-64.14.0-74.14.0-84.14.0-9
None listed
miniconda3-26
Docker Hardened Images:Debian:13
26.7.1-1-0 and later, plus listed versions
26.7.1-1-1
None listed
prefect-3
Docker Hardened Images:Debian:13
3.9.1-0 and later, plus listed versions
3.9.2-03.9.2-13.9.2-23.9.2-33.9.3-0
Show 14 more versionsShow less
3.9.3-13.9.3-23.9.4-03.9.4-13.9.4-23.9.4-33.9.4-43.9.5-03.9.5-13.9.6-03.9.6-13.9.6-23.9.6-33.9.6-4
None listed
python-semver
Ubuntu:16.04:LTS
All versions, plus listed versions
2.0.1-1
None listed
python-semver
Ubuntu:18.04:LTS
All versions, plus listed versions
2.0.1-22.0.1-3
None listed
python-semver
Ubuntu:20.04:LTS
All versions, plus listed versions
2.0.1-32.0.1-4
None listed
python-semver
Ubuntu:22.04:LTS
All versions, plus listed versions
2.10.2-22.10.2-3
None listed
python-semver
Ubuntu:24.04:LTS
All versions, plus listed versions
2.10.2-3
None listed
python-semver
Ubuntu:26.10
All versions, plus listed versions
3.0.2-1
None listed
python-semver
Ubuntu:26.04:LTS
All versions, plus listed versions
3.0.2-1
None listed

The JSON record also has 10 more versions.

Products 1

Exploits

Sources link exploit code, tools that only detect the flaw and other work on it, and most don’t say which a link is.

Exploit-related links
LinkSourceDate
googlesky/CVE-2026-140095PoC in GitHub2026-12-02

Sources

CVE List Score usedCVSS 4.08.7

python-semver: super-quadratic ReDoS in _LAST_NUMBER via attacker-controlled version strings

python-semver is a Python package for working with Semantic Versioning. Prior to 3.1.3, semver.Version.parse accepted an arbitrarily long alphabetic BUILD_IDENTIFIER and bump_build passed it through _increment_string to Version._LAST_NUMBER in src/semver/version.py. The expression contained ambiguous repeated non-digit quantifiers around a required digit run, causing super-quadratic backtracking when no digit was present and allowing an attacker-controlled valid version string to monopolize the Python process and deny service. This issue is fixed in version 3.1.3.

Record
CVE-2026-140095
CVSS 4.0
8.7 HighCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
Weakness
CWE-1333
Updated
2026-12-03
EUVDEUVD-2026-139743CVSS 4.08.7

python-semver is a Python package for working with Semantic Versioning. Prior to 3.1.3, semver.Version.parse accepted an arbitrarily long alphabetic BUILD_IDENTIFIER and bump_build passed it through _increment_string to Version._LAST_NUMBER in src/semver/version.py. The expression contained ambiguous repeated non-digit quantifiers around a required digit run, causing super-quadratic backtracking when no digit was present and allowing an attacker-controlled valid version string to monopolize the Python process and deny service. This issue is fixed in version 3.1.3.

Record
EUVD-2026-139743
CVSS 4.0
8.7 HighCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
Updated
2026-12-03
GitHub AdvisoriesGHSA-3qgw-g8j9-rcg4CVSS 4.08.7

python-semver: Super-quadratic ReDoS in _LAST_NUMBER via attacker-controlled version strings

Summary

python-semver/python-semver is the Python Semantic Versioning library published on PyPI as semver. At src/semver/version.py:95 it defines:

_LAST_NUMBER = re.compile(r"(?:[^\d]*(\d+)[^\d]*)+")

The pattern is used by bump_build() to find and increment the last numeric component of a version string's build metadata. Its outer repeated group (?:[^\d]*(\d+)[^\d]*)+ contains two unbounded [^\d]* quantifiers plus \d+, and adjacent repetitions can consume the same run of non-digit characters. When the build metadata is a long alphabetic string with no digits, the engine must try an enormous number of ways to divide that run among the quantifiers before the overall match fails, producing super-quadratic catastrophic backtracking, a CWE-1333 (Inefficient Regular Expression Complexity / ReDoS) condition.

The vulnerability is reachable end to end through the public API semver.Version.parse("1.0.0+" + "a" * N).bump_build(): the library's BUILD_IDENTIFIER rule is [0-9a-zA-Z-]+, so an arbitrarily long all-letter build identifier parses successfully and is then passed to the vulnerable search. The untrusted input surface is any version string supplied by an external party: package manifests and dependency constraints, version validation in CI and release pipelines, registry metadata, SBOM imports, update-check services, and multi-tenant version-policy validation. A roughly 32 KB build identifier blocks the parsing process for about 15 seconds, and longer values reach minute scale. Python's regular-expression engine cannot be interrupted by a timeout during that work.

The ambiguity inside _LAST_NUMBER is structural: the trailing [^\d]* of one iteration and the leading [^\d]* of the next iteration can consume the same characters, and there is no separator that forces a unique division. With no digit anywhere in the input, the engine keeps generating new candidate partitions for the outer +, each of which must then fail at the mandatory digits, until the search has explored a combinatorial number of possibilities. The control run with interleaved digits confirms that the presence of a matchable \d collapses the search to linear time.

Affected version

  • Repository: python-semver/python-semver; package: semver.
  • Affected release: latest release tag 3.1.0, with master HEAD f3c7138120d7f49e190bd7c555c6e7eb155b482d
  • Regex definition: src/semver/version.py:95.
  • Trigger chain: src/semver/version.py:424 (bump_build()) calls src/semver/version.py:452 (_increment_string(self._build)), which calls Version._LAST_NUMBER.search(string) at src/semver/version.py:324 inside _increment_string (lines 313-329).
  • Affected public entry point: semver.Version.parse(version_string).bump_build(), and any other public path that eventually calls _increment_string.

Reproduction and timing

All timings below were measured under CPython 3.12 with python-semver 3.1.0 in a controlled local environment. Isolated regex measurements are listed separately from the end-to-end public-API measurements.

Isolated _LAST_NUMBER search on a payload of 'a' * N with no digits:

n=1000   len=1000     7.34 ms
n=2000   len=2000    40.98 ms
n=4000   len=4000   161.87 ms
n=8000   len=8000   495.65 ms
n=16000  len=16000 1932.34 ms
n=32000  len=32000 16038.80 ms

End-to-end via the public API Version.parse('1.0.0+' + 'a' * N).bump_build() (first measurement series):

N=1000    8.1 ms
N=2000   30.5 ms  x3.8
N=4000  124.7 ms  x4.1
N=8000  459.2 ms  x3.7
N=16000 2001 ms   x4.4
N=32000 15177 ms  x7.6

A second end-to-end measurement series of the same call, recorded in the detailed evidence, gives:

N=1000    7.31 ms
N=2000   29.48 ms
N=4000  120.50 ms
N=8000  517.93 ms
N=16000 2091.86 ms
N=32000 15655.43 ms

The roughly fourfold cost for each doubling up to 16000 characters, followed by a larger factor at 32000, is consistent with quadratic behaviour that becomes…

Record
GHSA-3qgw-g8j9-rcg4
CVSS 4.0
8.7 HighCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
Weakness
CWE-1333
Updated
2026-12-04
NVDCVSS 4.08.7

python-semver is a Python package for working with Semantic Versioning. Prior to 3.1.3, semver.Version.parse accepted an arbitrarily long alphabetic BUILD_IDENTIFIER and bump_build passed it through _increment_string to Version._LAST_NUMBER in src/semver/version.py. The expression contained ambiguous repeated non-digit quantifiers around a required digit run, causing super-quadratic backtracking when no digit was present and allowing an attacker-controlled valid version string to monopolize the Python process and deny service. This issue is fixed in version 3.1.3.

Record
CVE-2026-140095
CVSS 4.0
8.7 HighCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
Weakness
CWE-1333
Updated
2026-12-03
OSVCVSS 4.08.7

python-semver: super-quadratic ReDoS in _LAST_NUMBER via attacker-controlled version strings

python-semver is a Python package for working with Semantic Versioning. Prior to 3.1.3, semver.Version.parse accepted an arbitrarily long alphabetic BUILD_IDENTIFIER and bump_build passed it through _increment_string to Version._LAST_NUMBER in src/semver/version.py. The expression contained ambiguous repeated non-digit quantifiers around a required digit run, causing super-quadratic backtracking when no digit was present and allowing an attacker-controlled valid version string to monopolize the Python process and deny service. This issue is fixed in version 3.1.3.

Record
CVE-2026-140095
CVSS 4.0
8.7 HighCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
Weakness
CWE-1333
Updated
2026-12-01
OSVDEBIAN-CVE-2026-140095CVSS 4.08.7

python-semver is a Python package for working with Semantic Versioning. Prior to 3.1.3, semver.Version.parse accepted an arbitrarily long alphabetic BUILD_IDENTIFIER and bump_build passed it through _increment_string to Version._LAST_NUMBER in src/semver/version.py. The expression contained ambiguous repeated non-digit quantifiers around a required digit run, causing super-quadratic backtracking when no digit was present and allowing an attacker-controlled valid version string to monopolize the Python process and deny service. This issue is fixed in version 3.1.3.

Record
DEBIAN-CVE-2026-140095
CVSS 4.0
8.7 HighCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
Updated
2026-12-04
OSVDHI-kcuu-s5ml-tfvv-qvfpCVSS 4.08.7

python-semver is a Python package for working with Semantic Versioning. Prior to 3.1.3, semver.Version.parse accepted…

python-semver is a Python package for working with Semantic Versioning. Prior to 3.1.3, semver.Version.parse accepted an arbitrarily long alphabetic BUILD_IDENTIFIER and bump_build passed it through _increment_string to Version._LAST_NUMBER in src/semver/version.py. The expression contained ambiguous repeated non-digit quantifiers around a required digit run, causing super-quadratic backtracking when no digit was present and allowing an attacker-controlled valid version string to monopolize the Python process and deny service. This issue is fixed in version 3.1.3.

Record
DHI-kcuu-s5ml-tfvv-qvfp
CVSS 4.0
8.7 HighCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
Updated
2026-12-05
OSVGHSA-3qgw-g8j9-rcg4CVSS 4.08.7

python-semver: Super-quadratic ReDoS in _LAST_NUMBER via attacker-controlled version strings

Summary

python-semver/python-semver is the Python Semantic Versioning library published on PyPI as semver. At src/semver/version.py:95 it defines:

_LAST_NUMBER = re.compile(r"(?:[^\d]*(\d+)[^\d]*)+")

The pattern is used by bump_build() to find and increment the last numeric component of a version string's build metadata. Its outer repeated group (?:[^\d]*(\d+)[^\d]*)+ contains two unbounded [^\d]* quantifiers plus \d+, and adjacent repetitions can consume the same run of non-digit characters. When the build metadata is a long alphabetic string with no digits, the engine must try an enormous number of ways to divide that run among the quantifiers before the overall match fails, producing super-quadratic catastrophic backtracking, a CWE-1333 (Inefficient Regular Expression Complexity / ReDoS) condition.

The vulnerability is reachable end to end through the public API semver.Version.parse("1.0.0+" + "a" * N).bump_build(): the library's BUILD_IDENTIFIER rule is [0-9a-zA-Z-]+, so an arbitrarily long all-letter build identifier parses successfully and is then passed to the vulnerable search. The untrusted input surface is any version string supplied by an external party: package manifests and dependency constraints, version validation in CI and release pipelines, registry metadata, SBOM imports, update-check services, and multi-tenant version-policy validation. A roughly 32 KB build identifier blocks the parsing process for about 15 seconds, and longer values reach minute scale. Python's regular-expression engine cannot be interrupted by a timeout during that work.

The ambiguity inside _LAST_NUMBER is structural: the trailing [^\d]* of one iteration and the leading [^\d]* of the next iteration can consume the same characters, and there is no separator that forces a unique division. With no digit anywhere in the input, the engine keeps generating new candidate partitions for the outer +, each of which must then fail at the mandatory digits, until the search has explored a combinatorial number of possibilities. The control run with interleaved digits confirms that the presence of a matchable \d collapses the search to linear time.

Affected version

  • Repository: python-semver/python-semver; package: semver.
  • Affected release: latest release tag 3.1.0, with master HEAD f3c7138120d7f49e190bd7c555c6e7eb155b482d; the pattern is present in both and unfixed.
  • Regex definition: src/semver/version.py:95.
  • Trigger chain: src/semver/version.py:424 (bump_build()) calls src/semver/version.py:452 (_increment_string(self._build)), which calls Version._LAST_NUMBER.search(string) at src/semver/version.py:324 inside _increment_string (lines 313-329).
  • Affected public entry point: semver.Version.parse(version_string).bump_build(), and any other public path that eventually calls _increment_string.

Reproduction and timing

All timings below were measured under CPython 3.12 with python-semver 3.1.0 in a controlled local environment. Isolated regex measurements are listed separately from the end-to-end public-API measurements.

Isolated _LAST_NUMBER search on a payload of 'a' * N with no digits:

n=1000   len=1000     7.34 ms
n=2000   len=2000    40.98 ms
n=4000   len=4000   161.87 ms
n=8000   len=8000   495.65 ms
n=16000  len=16000 1932.34 ms
n=32000  len=32000 16038.80 ms

End-to-end via the public API Version.parse('1.0.0+' + 'a' * N).bump_build() (first measurement series):

N=1000    8.1 ms
N=2000   30.5 ms  x3.8
N=4000  124.7 ms  x4.1
N=8000  459.2 ms  x3.7
N=16000 2001 ms   x4.4
N=32000 15177 ms  x7.6

A second end-to-end measurement series of the same call, recorded in the detailed evidence, gives:

N=1000    7.31 ms
N=2000   29.48 ms
N=4000  120.50 ms
N=8000  517.93 ms
N=16000 2091.86 ms
N=32000 15655.43 ms

The roughly fourfold cost for each doubling up to 16000 characters, followed by a larger factor at 32000, is consistent…

Record
GHSA-3qgw-g8j9-rcg4
CVSS 4.0
8.7 HighCVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
Weakness
CWE-1333
Updated
2026-12-01
OSVUBUNTU-CVE-2026-140095No score

(python-semver is a Python package for working with Semantic Versioning ...)

Record
UBUNTU-CVE-2026-140095
Updated
2026-12-03

The JSON record also has the rest of 2 source descriptions.

History

Recorded by Every CVE

Changes recorded by Every CVE
DayChangedSources
Affected packagesOSV
Affected packagesOSV
Affected packagesGitHub Advisories, OSV
Affected packagesOSV
Affected packagesOSV
Affected packagesOSV
Affected packagesOSV
Affected packages, other IDs, referencesOSV
Affected packagesOSV
Published dateEUVD, NVD
Key facts, referencesCVE List
Affected packagesOSV
ReferencesOSV
Exploit links, key factsPoC in GitHub
Affected packagesOSV
Affected packagesOSV
Affected packagesOSV
Affected packagesOSV
Affected packagesOSV
Affected packages, other IDs, referencesOSV
Affected packagesOSV
Affected packages, other IDs, references, severityOSV
Published dateEUVD
Affected packages, referencesOSV
Affected packages, key facts, referencesGitHub Advisories
Other IDs, referencesOSV
SeverityNVD
Other IDs, published dateEUVD
First indexedCVE List

Upstream dates may differ.

References

Show 4 more referencesShow less
MoveEnter Open