Skip to content

fix(interpreter): cap global pattern replacement result size#1017

Merged
chaliy merged 1 commit intomainfrom
fix/issue-995-unbounded-replacement
Apr 2, 2026
Merged

fix(interpreter): cap global pattern replacement result size#1017
chaliy merged 1 commit intomainfrom
fix/issue-995-unbounded-replacement

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 2, 2026

Summary

  • Add 10MB cap on global pattern replacement (${var//pattern/repl}) output size
  • Prevents memory amplification where 10KB input could produce 10MB+ output
  • Caps both simple string and recursive glob replacement paths

Closes #995

Test plan

  • New spec tests: replace_pattern_limit.test.sh with 3 cases
  • cargo test --all-features passes
  • cargo clippy -- -D warnings clean

Closes #995 — global pattern replacement ${var//pattern/repl} could
produce unbounded output when replacement is longer than the matched
text. Adds MAX_EXPANSION_RESULT_BYTES (10MB) check to both simple
string replacement and recursive glob replacement paths.
@chaliy chaliy merged commit 747cda7 into main Apr 2, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-995-unbounded-replacement branch April 2, 2026 14:53
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.

Global pattern replacement ${var//pattern/repl} enables unbounded string growth

1 participant