Skip to content

Limit regex remap substitutions#13139

Open
bneradt wants to merge 1 commit into
apache:masterfrom
bneradt:regex-remap-substitution-limit
Open

Limit regex remap substitutions#13139
bneradt wants to merge 1 commit into
apache:masterfrom
bneradt:regex-remap-substitution-limit

Conversation

@bneradt
Copy link
Copy Markdown
Contributor

@bneradt bneradt commented May 6, 2026

Regex remap targets could repeat valid substitution markers enough times
to exceed the fixed substitution arrays, even when every marker referred
to an allowed capture group.

This rejects targets with more substitution markers than the parser can
store and covers the boundary with remap parser unit tests.

Regex remap targets could repeat valid substitution markers enough times
to exceed the fixed substitution arrays, even when every marker referred
to an allowed capture group.

This rejects targets with more substitution markers than the parser can
store and covers the boundary with remap parser unit tests.
@bneradt bneradt added this to the 11.0.0 milestone May 6, 2026
@bneradt bneradt self-assigned this May 6, 2026
@ezelkow1
Copy link
Copy Markdown
Member

ezelkow1 commented May 7, 2026

[approve ci]

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens regex remap parsing by enforcing an upper bound on the number of substitution markers ($0..$9) allowed in a regex remap target, preventing overflow of the fixed-size substitution arrays in UrlRewrite::RegexMapping. It also adds unit tests that exercise the boundary condition (max allowed vs. one over the limit).

Changes:

  • Reject regex remap targets whose host template contains more than UrlRewrite::MAX_REGEX_SUBS substitution markers.
  • Add unit tests validating that parsing succeeds at the limit and fails when exceeding it.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/proxy/http/remap/unit-tests/test_RemapRules.cc Adds boundary unit tests for regex remap substitution marker count.
src/proxy/http/remap/RemapConfig.cc Adds a guard to fail parsing when substitution markers exceed MAX_REGEX_SUBS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants