CVE-2026-140095: 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 BUILDIDENTIFIER and bumpbuild passed it through incrementstring to Version.LASTNUMBER 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.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 3.1.3
Event History
Frequently Asked Questions
What conditions must be met for exploitation?
An attacker must be able to supply a valid version string whose build identifier is arbitrarily long and alphabetic, and the application must pass it through semver.Version.parse and then bump_build. The denial of service occurs when the build identifier contains no digit, triggering super-quadratic regex backtracking.
Who is realistically exposed?
Applications that process attacker-controlled semantic version strings and invoke bump_build on the parsed version are exposed. The vulnerable behavior can monopolize the Python process, so services that handle such input synchronously are particularly at risk.
What should be done if immediate patching is not possible?
Restrict or reject unbounded build identifiers from untrusted inputs, especially long alphabetic identifiers without digits, before parsing or calling bump_build. Apply length limits to version strings and build metadata to prevent excessive regex processing.
How can I determine whether my deployment is affected?
Check whether python-semver is installed at a version earlier than 3.1.3 and whether your code accepts untrusted version strings that can reach Version.parse followed by bump_build. Version 3.1.3 contains the fix.