fix: X-Forwarded-Proto rejected when allowedDomains includes protocol field#15560
Merged
matthewp merged 1 commit intowithastro:mainfrom Feb 18, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: 31af714 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
… and hostname
The protocol validation in validateForwardedHeaders() passed the full pattern
object to matchPattern(), which also checked hostname against the hardcoded
test URL (example.com). Pass only { protocol } to matchPattern() so that only
the protocol field is validated; the host+proto combination is already checked
in the host validation block below.
Fixes withastro#15559
f48a3f6 to
31af714
Compare
Merging this PR will improve performance by 32.87%
Performance Changes
Comparing Footnotes |
matthewp
approved these changes
Feb 17, 2026
Merged
qzio
pushed a commit
to qzio/astro
that referenced
this pull request
Feb 20, 2026
… and hostname (withastro#15560) The protocol validation in validateForwardedHeaders() passed the full pattern object to matchPattern(), which also checked hostname against the hardcoded test URL (example.com). Pass only { protocol } to matchPattern() so that only the protocol field is validated; the host+proto combination is already checked in the host validation block below. Fixes withastro#15559
This was referenced Feb 20, 2026
1 task
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.
The protocol validation in
validateForwardedHeaders()passed the full pattern object tomatchPattern(), which also checked hostname against the hardcoded test URL (example.com). Pass only{ protocol }tomatchPattern()so that only the protocol field is validated; the host+proto combination is already checked in the host validation block below.Fixes #15559
Changes
{ protocol: pattern.protocol }instead of the full pattern tomatchPattern()in the protocol validation blockTesting
Added 4 unit tests in
node.test.jscovering the reverse proxy case (socket.encrypted: false):httpswhenallowedDomainshas protocol + hostnamehttpwhen onlyhttpsis allowedhttpswith wildcard hostname patternDocs
No docs changes needed — this restores the documented behavior of
security.allowedDomains.