Skip to content

Fix DurationType regex vulnerability and add tests#160

Merged
slott56 merged 1 commit intocloud-custodian:mainfrom
outlookenjoyer:fix-duration-regex
Mar 18, 2026
Merged

Fix DurationType regex vulnerability and add tests#160
slott56 merged 1 commit intocloud-custodian:mainfrom
outlookenjoyer:fix-duration-regex

Conversation

@outlookenjoyer
Copy link
Contributor

Fixes #147 #155

Description

The old regex used [a-z]+ to parse time units, which caused the regex engine to hang on bad inputs like mmmmmmmmmm!

Changes

  • Swapped [a-z]+ with a hardcoded list of valid units (ms, s, h, etc.)
  • Sorted the units by length so ms matches safely before m
  • Added tests

Verification

  • Tests pass (pytest tests/test_celtypes.py)

cc @slott56

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 21, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: outlookenjoyer / name: Rustam (2a663e8)

Copy link
Collaborator

@slott56 slott56 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very tidy.

@slott56 slott56 merged commit b537587 into cloud-custodian:main Mar 18, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possible ReDoS Security Issue in duration_pat Regex (celtypes.py:1333)

2 participants