Repository navigation
🛡️ feat(config): let a listener allowlist underscore-named fields - #324
Merged
Merged
Conversation
Implement Caddy's `expected_underscore_headers` server option: exact names and trailing-star prefixes survive on the listeners that list them, the matching hyphenated spelling is dropped so the alias cannot reach the same CGI variable, and a repeated allowlisted field drops every occurrence. Without the option the default is unchanged — every underscore name is dropped before routing. The allowlist is compiled once per listener and shared by the H1/H2 filter and the H3 parser, so one configuration cannot route two ways (#269). Two files disagreeing about the list are refused, like `client_ip_headers`. Fixes #295 Co-authored-by: Codex <codex@openai.com>
Owner
Author
|
@codex check |
|
To use Codex here, create an environment for this repo. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 What this changes
Implement Caddy's
expected_underscore_headersserver option: exact names andtrailing-star prefixes survive on the listeners that list them, the hyphenated
spelling of an allowlisted name is dropped, and a repeated allowlisted field
drops every occurrence. Without the option nothing changes — every underscore
name is still dropped before routing.
Closes #295.
🤔 Why
Underscore-named fields were dropped unconditionally, because a CGI or FastCGI
backend folds
x_probeandx-probeonto the same variable and a client couldspoof the identity headers
forward_auth copy_headersowns(GHSA-f59h-q822-g45g). An origin that legitimately needs such a field had no way
to keep it; Caddy's
expected_underscore_headersis that way, and this buildfollows the current upstream semantics rather than the option's first draft in
the issue.
🔬 Evidence
pingclair/tests/integration/underscore_headers.rs(new, real binary, H1).With the proxy wiring removed the allowlist test fails against the origin's
view —
["webhook-event", "x-probe"]instead of["webhook_event", "x_probe"]— and passes with it.scripts/h3-go/underscore_headers_test.go(new, real binary) asserts thesame policy over H1, H2 and H3 in one test, including the hyphenated-alias,
dot-suffix and duplicate rules;
just h3-go-testpasses in full.pingclair-proxy/src/header_alias.rsunit tests pin exact, prefix, alias andduplicate semantics;
pingclair-configtests cover entry validation and therefusal when two files disagree about the list.
just ci: 2,081 tests passed, 10 skipped; clippy, shear, repository lint,docs lint and benchmark smoke green.
git diff --checkpasses.🔀 Both transports?
request_filterpath, exercised by theRust integration test (H1) and the Go suite (H1 and H2).
exercised end to end by
just h3-go-test.📚 Documentation
CHANGELOG.md describes the new option, its default, and the alias and duplicate
rules.
🤖 Which AI helped?
Codex wrote the change and tests and ran the validation; Dorian reviewed the
approach (Caddy's whitelist semantics) before implementation.