Skip to content

header_rewrite: reject a modifier-only config line - #13650

Open
bneradt wants to merge 1 commit into
apache:masterfrom
bneradt:header-rewrite-modifier-only-line
Open

header_rewrite: reject a modifier-only config line#13650
bneradt wants to merge 1 commit into
apache:masterfrom
bneradt:header-rewrite-modifier-only-line

Conversation

@bneradt

@bneradt bneradt commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

A header_rewrite configuration line consisting of nothing but a
modifier section, such as a stray "[L]", crashes Traffic Server at
config load time. The parser consumes the trailing modifiers with a
pop_back() and then indexes tokens[0] unconditionally, so an empty
token list is read out of bounds. On a hardened build that aborts
during plugin init, which takes the whole server down; elsewhere it is
a read of a destroyed std::string. Any operator who can write a
header_rewrite config can trigger it.

This patch guards the token list after the modifier section is
consumed. A line with no condition or operator left is not a valid
rule, so the parser now reports the offending modifiers with TSError
and returns false, which the existing caller already handles by
logging the line number and skipping the line. The rest of the config
loads normally.

This change also adds a unit test covering both a short, small-string
optimized modifier token and a longer heap allocated one, plus an
end-to-end autest that loads such a config and verifies that Traffic
Server starts, logs the rejection, and still applies the surrounding
rules.

Fixes: #13639

Co-authored-by: Claude Opus 5

Copilot AI lite review requested due to automatic review settings September 8, 2026 19:55
@bneradt bneradt added this to the 11.0.0 milestone Sep 8, 2026
@bneradt bneradt self-assigned this Sep 8, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@bneradt bneradt added Plugins header_rewrite header_rewrite plugin Crash Bug AuTest Tests Backport Marked for backport for an LTS patch release labels Sep 8, 2026
A header_rewrite configuration line consisting of nothing but a
modifier section, such as a stray "[L]", crashes Traffic Server at
config load time. The parser consumes the trailing modifiers with a
pop_back() and then indexes tokens[0] unconditionally, so an empty
token list is read out of bounds. On a hardened build that aborts
during plugin init, which takes the whole server down; elsewhere it is
a read of a destroyed std::string. Any operator who can write a
header_rewrite config can trigger it.

This patch guards the token list after the modifier section is
consumed. A line with no condition or operator left is not a valid
rule, so the parser now reports the offending modifiers with TSError
and returns false, which the existing caller already handles by
logging the line number and skipping the line. The rest of the config
loads normally.

This change also adds a unit test covering both a short, small-string
optimized modifier token and a longer heap allocated one, plus an
end-to-end autest that loads such a config and verifies that Traffic
Server starts, logs the rejection, and still applies the surrounding
rules.

Fixes: apache#13639

Co-authored-by: Claude Opus 5
@bneradt
bneradt force-pushed the header-rewrite-modifier-only-line branch from 3e0e16d to 8795a45 Compare September 8, 2026 20:35
Copilot AI review requested due to automatic review settings September 8, 2026 20:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Labels

AuTest Backport Marked for backport for an LTS patch release Bug Crash header_rewrite header_rewrite plugin Plugins Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

header_rewrite: Parser::preprocess() indexes tokens[0] after pop_back() can empty the vector

2 participants