Skip to content

common: fix catastrophic backtracking in release regexes - #272

Merged
lubomir merged 1 commit into
release-engineering:masterfrom
prownd:common-fix-catastrophic-backtracking-in-release-regexes-s01
Oct 23, 2026
Merged

lubomir merged 1 commit into
release-engineering:masterfrom
prownd:common-fix-catastrophic-backtracking-in-release-regexes-s01

Conversation

@prownd

@prownd prownd commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

RELEASE_SHORT_RE, RELEASE_TYPE_RE and RELEASE_VERSION_RE contained nested quantifiers (([a-z0-9]*-?[a-z0-9]+)* and (\.?[0-9]+)*). On a long non-matching input the regex engine backtracks exponentially: validating a release short name of 22 letters followed by "!" took more than 75 seconds.

RELEASE_VERSION_RE is applied to the version field when deserializing composeinfo.json, which may be fetched from a remote server, so a crafted metadata file can hang any consumer (ReDoS).

Rewrite the expressions without nested quantifiers. The accepted language is unchanged (verified by exhaustively comparing old and new expressions on all strings up to 8 characters over a representative alphabet).

RELEASE_SHORT_RE, RELEASE_TYPE_RE and RELEASE_VERSION_RE contained
nested quantifiers (`([a-z0-9]*-?[a-z0-9]+)*` and `(\.?[0-9]+)*`).
On a long non-matching input the regex engine backtracks exponentially:
validating a release short name of 22 letters followed by "!" took more
than 75 seconds.

RELEASE_VERSION_RE is applied to the version field when deserializing
composeinfo.json, which may be fetched from a remote server, so a
crafted metadata file can hang any consumer (ReDoS).

Rewrite the expressions without nested quantifiers. The accepted
language is unchanged (verified by exhaustively comparing old and new
expressions on all strings up to 8 characters over a representative
alphabet).
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.71%. Comparing base (b01c4cf) to head (e7be43e).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #272   +/-   ##
=======================================
  Coverage   79.71%   79.71%           
=======================================
  Files          10       10           
  Lines        2061     2061           
=======================================
  Hits         1643     1643           
  Misses        418      418           
Flag Coverage Δ
unit-tests 79.71% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
productmd/common.py 86.61% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lubomir

lubomir commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Thanks for the patch.

@lubomir lubomir added the sync development Cherry-pick this PR into the development branch on merge label Oct 23, 2026
@lubomir
lubomir merged commit 9b653ff into release-engineering:master Oct 23, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sync development Cherry-pick this PR into the development branch on merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants