Repository navigation
fastcgi: let configured env variables override request headers - #8358
Merged
Merged
Conversation
Member
|
Rebase does need to retain the Host-header guard. Plus this is GHSA-q34h-28rj-5hjm |
buildEnv applied the env subdirective before copying request headers,
so a client header replaced any HTTP_* variable the operator set. With
"env HTTP_X_AUTH_USER {http.auth.user.id}", a client sending
"X-Auth-User: admin" chose the value the backend saw.
Apply the configured variables last, as FrankenPHP does for its
prepared environment.
dunglas
force-pushed
the
fastcgi-env-precedence
branch
from
November 4, 2026 20:29
3032467 to
cc66625
Compare
steadytao
approved these changes
Nov 4, 2026
Member
|
@francislavoie will let you cut. Please use that GHSA rather than a new one 🫡 |
francislavoie
pushed a commit
that referenced
this pull request
Nov 5, 2026
(cherry picked from commit 70dca34)
5 tasks
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.
Security fix. A client could override any
HTTP_*variable set with theenvsubdirective of the FastCGI transport (andphp_fastcgi).buildEnvapplied the configured variables first, then copied the request headers asHTTP_*, so a header with a matching name won. For instance:A client sending
X-Auth-User: adminchose the user the PHP application saw, bypassing authentication done by Caddy, andX-Forwarded-Proto: httpreplaced the pinned scheme. OnlyHTTP_*names are affected, since only those can come from headers. The behavior dates back to the FastCGI transport's introduction in 026df7c5.This applies the configured variables last, so the operator's value always wins. FrankenPHP already gives its prepared environment the last word: php/frankenphp@d25d295f
Behavior change: a configuration relying on a request header replacing an
envvalue (a default the client may override) no longer works. Such a fallback can be written with a placeholder, e.g.env HTTP_X_FOO {http.request.header.X-Foo}.This issue was not reported through a security advisory; it was found while porting FrankenPHP fixes to Caddy.
Assistance Disclosure
Claude Code (Claude Opus 5.5) found this issue while comparing the Caddy and FrankenPHP FastCGI environments, and wrote the fix and the test. I reviewed and tested the result.