Repository navigation
chore(deps): update dependency semver to v3.1.3 [security] - #6490
Merged
cuixq merged 1 commit intoDec 2, 2026
Merged
Conversation
cuixq
approved these changes
Dec 2, 2026
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.
This PR contains the following updates:
3.1.2→3.1.3python-semver: Super-quadratic ReDoS in _LAST_NUMBER via attacker-controlled version strings
CVE-2026-140095 / GHSA-3qgw-g8j9-rcg4
More information
Details
Summary
python-semver/python-semveris the Python Semantic Versioning library published on PyPI assemver. Atsrc/semver/version.py:95it defines: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'sBUILD_IDENTIFIERrule 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_NUMBERis 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\dcollapses the search to linear time.Affected version
python-semver/python-semver; package:semver.3.1.0, with master HEADf3c7138120d7f49e190bd7c555c6e7eb155b482d; the pattern is present in both and unfixed.src/semver/version.py:95.src/semver/version.py:424(bump_build()) callssrc/semver/version.py:452(_increment_string(self._build)), which callsVersion._LAST_NUMBER.search(string)atsrc/semver/version.py:324inside_increment_string(lines 313-329).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_NUMBERsearch on a payload of'a' * Nwith no digits:End-to-end via the public API
Version.parse('1.0.0+' + 'a' * N).bump_build()(first measurement series):A second end-to-end measurement series of the same call, recorded in the detailed evidence, gives:
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 super-quadratic at larger sizes. A control run using a payload of
'a1' * N, which does contain digits, stays linear and confirms that the blowup is specifically triggered by a long run with no\dmatch:Reachability
No special configuration is needed. A caller passes a syntactically valid semantic version whose build component is a long run of letters;
Version.parseaccepts it becauseBUILD_IDENTIFIERis[0-9a-zA-Z-]+and imposes no length limit. Callingbump_build()then readsself._build, passes it to_increment_string, and reaches_LAST_NUMBER.search. Because the version string itself is attacker-controlled in many integration paths, an external party can choose both that it parses successfully and that the subsequent increment becomes arbitrarily expensive. There is no input length validation at the parse, build, or increment stages, and the search cannot be aborted once it starts backtracking.In practice the untrusted version string can arrive through a
requirements.txtor lock file submitted for analysis, a tag or version number checked by a release pipeline, registry or SBOM metadata imported from a third party, an update-check response, or a tenant-supplied policy in a multi-tenant service. In each case the caller typically parses first and only afterwards decides whether the version is acceptable, so an attacker does not need the string to survive validation: successful parsing with an expensive subsequent increment is enough.Impact
The principal consequence is denial of service. A single call with a 32 KB all-letter build identifier consumes about 15 seconds of CPU in the parsing process; a small number of concurrent calls can occupy all available workers and make a service unresponsive. The trigger is a valid version string, so it passes ordinary validation, and the amplification ratio is severe: doubling the input roughly quadruples the cost, with a worse factor at the largest measured size. The affected code sits in a public parsing and increment API, so any downstream application that consumes untrusted version strings from manifests, registry metadata, CI inputs, or client submissions is exposed. This is rated High because the input threshold is low, the amplification is clearly measured, the path is public API, and no privileges are required; the impact is availability only, with no data disclosure or code execution, so it is not Critical.
The measured progression illustrates the risk: about 8 ms at 1000 characters, just over 2 seconds at 16000, and roughly 15 seconds at 32000. A service that accepts version strings over the network can therefore be pushed from negligible latency to a full CPU stall by a single modest payload, and the super-quadratic step at the largest size means the effect grows faster than the amount of data sent.
Suggested fix
re.compile(r'\d+')withfinditerand keep the final match, use a bounded-backtracking form such as(\d+)(?!.*\d), or perform a hand-written right-to-left scan. Preserve the existing_increment_stringsemantics formatch.group(1)andmatch.span(1).Version.parseandbump_build, rejecting longer values outright.'a' * N, so a future reintroduction of the nested quantifier is caught.Taken together, rewriting the expression and bounding the input length remove both the computational flaw and the ability of an attacker to feed it an arbitrarily large value. The regression test should include the all-letter build identifier as well as other digit-free strings, since the vulnerable condition is the absence of a digit rather than the specific character used.
Disclosure
Reported by Jiawei Guo (GitHub: plailenceGrill).
Severity
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:NReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
python-semver: Super-quadratic ReDoS in _LAST_NUMBER via attacker-controlled version strings
CVE-2026-140095 / GHSA-3qgw-g8j9-rcg4
More information
Details
Summary
python-semver/python-semveris the Python Semantic Versioning library published on PyPI assemver. Atsrc/semver/version.py:95it defines: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'sBUILD_IDENTIFIERrule 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_NUMBERis 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\dcollapses the search to linear time.Affected version
python-semver/python-semver; package:semver.3.1.0, with master HEADf3c7138120d7f49e190bd7c555c6e7eb155b482d; the pattern is present in both and unfixed.src/semver/version.py:95.src/semver/version.py:424(bump_build()) callssrc/semver/version.py:452(_increment_string(self._build)), which callsVersion._LAST_NUMBER.search(string)atsrc/semver/version.py:324inside_increment_string(lines 313-329).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_NUMBERsearch on a payload of'a' * Nwith no digits:End-to-end via the public API
Version.parse('1.0.0+' + 'a' * N).bump_build()(first measurement series):A second end-to-end measurement series of the same call, recorded in the detailed evidence, gives:
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 super-quadratic at larger sizes. A control run using a payload of
'a1' * N, which does contain digits, stays linear and confirms that the blowup is specifically triggered by a long run with no\dmatch:Reachability
No special configuration is needed. A caller passes a syntactically valid semantic version whose build component is a long run of letters;
Version.parseaccepts it becauseBUILD_IDENTIFIERis[0-9a-zA-Z-]+and imposes no length limit. Callingbump_build()then readsself._build, passes it to_increment_string, and reaches_LAST_NUMBER.search. Because the version string itself is attacker-controlled in many integration paths, an external party can choose both that it parses successfully and that the subsequent increment becomes arbitrarily expensive. There is no input length validation at the parse, build, or increment stages, and the search cannot be aborted once it starts backtracking.In practice the untrusted version string can arrive through a
requirements.txtor lock file submitted for analysis, a tag or version number checked by a release pipeline, registry or SBOM metadata imported from a third party, an update-check response, or a tenant-supplied policy in a multi-tenant service. In each case the caller typically parses first and only afterwards decides whether the version is acceptable, so an attacker does not need the string to survive validation: successful parsing with an expensive subsequent increment is enough.Impact
The principal consequence is denial of service. A single call with a 32 KB all-letter build identifier consumes about 15 seconds of CPU in the parsing process; a small number of concurrent calls can occupy all available workers and make a service unresponsive. The trigger is a valid version string, so it passes ordinary validation, and the amplification ratio is severe: doubling the input roughly quadruples the cost, with a worse factor at the largest measured size. The affected code sits in a public parsing and increment API, so any downstream application that consumes untrusted version strings from manifests, registry metadata, CI inputs, or client submissions is exposed. This is rated High because the input threshold is low, the amplification is clearly measured, the path is public API, and no privileges are required; the impact is availability only, with no data disclosure or code execution, so it is not Critical.
The measured progression illustrates the risk: about 8 ms at 1000 characters, just over 2 seconds at 16000, and roughly 15 seconds at 32000. A service that accepts version strings over the network can therefore be pushed from negligible latency to a full CPU stall by a single modest payload, and the super-quadratic step at the largest size means the effect grows faster than the amount of data sent.
Suggested fix
re.compile(r'\d+')withfinditerand keep the final match, use a bounded-backtracking form such as(\d+)(?!.*\d), or perform a hand-written right-to-left scan. Preserve the existing_increment_stringsemantics formatch.group(1)andmatch.span(1).Version.parseandbump_build, rejecting longer values outright.'a' * N, so a future reintroduction of the nested quantifier is caught.Taken together, rewriting the expression and bounding the input length remove both the computational flaw and the ability of an attacker to feed it an arbitrarily large value. The regression test should include the all-letter build identifier as well as other digit-free strings, since the vulnerable condition is the absence of a digit rather than the specific character used.
Disclosure
Reported by Jiawei Guo (GitHub: plailenceGrill).
Severity
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:NReferences
This data is provided by OSV and the GitHub Advisory Database (CC-BY 4.0).
Release Notes
python-semver/python-semver (semver)
v3.1.3Compare Source
=============
:Released: 2026-11-26
:Maintainer: Tom Schraitle
Security
For details, see
GHSA-3qgw-g8j9-rcg4 <https://github.com/python-semver/python-semver/security/advisories/GHSA-3qgw-g8j9-rcg4>_.Bug Fixes
:gh:
515: Fix :meth:Version.__hash__so that versions which compare equal now produceequal hashes. A numeric prerelease identifier with leading zeros (for example
"007") compares equal to its normalized form ("7"), but previouslyhashed differently, which broke
setanddictbehavior.Fix GitHub Python test to use pinned versions in :file:
pyproject.toml.Improved Documentation
514: The prefixed-version documentation example now rejects empty input withValueError, allowing its inheritedis_validmethod to returnFalse.Configuration
📅 Schedule: (in timezone Australia/Sydney)
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.