Skip to content

fix(builtins): enforce regex size limits in sed, grep, and awk#1049

Merged
chaliy merged 3 commits intomainfrom
fix/issue-984-regex-size-limit
Apr 4, 2026
Merged

fix(builtins): enforce regex size limits in sed, grep, and awk#1049
chaliy merged 3 commits intomainfrom
fix/issue-984-regex-size-limit

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 3, 2026

Summary

  • Add build_regex() / build_regex_opts() helpers in search_common.rs enforcing 1MB size and DFA limits
  • Replace all user-facing Regex::new() and RegexBuilder::new() calls in sed (3), grep (1), awk (8) with bounded helpers
  • Internal constant patterns left as-is (safe, known-small)

Test plan

  • Grep rejects huge regex pattern (50K alternations)
  • Sed rejects huge regex pattern
  • AWK rejects huge regex in match()
  • Normal regex patterns still compile and work
  • All existing spec tests pass

Closes #984

chaliy added 3 commits April 3, 2026 23:37
Add build_regex() and build_regex_opts() helpers in search_common.rs
that enforce 1MB size_limit and dfa_size_limit on all compiled regexes.
Replace all Regex::new() and RegexBuilder::new() calls in sed.rs,
grep.rs, awk.rs, and search_common.rs with these helpers.

Closes #984
@chaliy chaliy merged commit 28d0702 into main Apr 4, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-984-regex-size-limit branch April 4, 2026 01:15
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.

No regex size/complexity limit in sed, grep, and awk enables resource exhaustion

1 participant