Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: x-forwarded-proto is sanitized now #61

Merged
merged 6 commits into from
Aug 24, 2022

Conversation

nickytonline
Copy link

@nickytonline nickytonline commented Aug 24, 2022

Description

Fixes an issue where someone can inject a non-standard value in the x-forwarded-proto header.

Related Issues and Documents

/~https://github.com/netlify/pod-ecosystem-frameworks/issues/208

@github-actions github-actions bot added the type: bug code to address defects in shipped code label Aug 24, 2022
src/index.ts Outdated
@@ -30,6 +32,8 @@ export function createIPXHandler ({
}
const handler: Handler = async (event, _context) => {
const host = event.headers.host
event.headers['x-forwarded-proto'] = X_FORWARDED_PROTO_VALUES.includes(event.headers['x-forwarded-proto'].toLowerCase()) ? event.headers['x-forwarded-proto'] : 'http'
Copy link
Author

Choose a reason for hiding this comment

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

Now we only allow the allowed values for x-forwarded-proto.

dustincrogers
dustincrogers previously approved these changes Aug 24, 2022
Copy link

@dustincrogers dustincrogers left a comment

Choose a reason for hiding this comment

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

lgtm

@nickytonline nickytonline marked this pull request as ready for review August 24, 2022 22:07
@nickytonline nickytonline requested a review from a team August 24, 2022 22:07
dustincrogers
dustincrogers previously approved these changes Aug 24, 2022
src/index.ts Outdated
@@ -30,7 +30,7 @@ export function createIPXHandler ({
}
const handler: Handler = async (event, _context) => {
const host = event.headers.host
const protocol = event.headers['x-forwarded-proto'] || 'http'
const protocol = event.headers['x-nf-connection-proto'] || 'http'
Copy link
Author

Choose a reason for hiding this comment

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

@mraerino mentioned this as a better option as it can't be tampered with.

@nickytonline nickytonline marked this pull request as draft August 24, 2022 22:35
@nickytonline nickytonline marked this pull request as ready for review August 24, 2022 22:43
Co-authored-by: Marcus Weiner <marcus.weiner@gmail.com>
mraerino
mraerino previously approved these changes Aug 24, 2022
@nickytonline nickytonline merged commit dfa7505 into main Aug 24, 2022
@nickytonline nickytonline deleted the nickytonline/x-forwarded-proto-fix branch August 24, 2022 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants