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

req.hostname: check first comma-delimited host #3495

Merged
merged 1 commit into from
Oct 28, 2018

Conversation

iconoeugen
Copy link
Contributor

Fixes #3494

@dsingleton
Copy link

We (Deliveroo) ran into this issue recently. We're working around it for now, but it would be great to get merged/released. Anything we can do to help?

@dougwilson
Copy link
Contributor

This is planned to be merged in the next minor release. We are currently working though 3 different security reports since Jan 1 and that is where are bandwidth is at, as we're trying to get security issues addresses ASAP. I hope that makes sense. Depending on if a security update will require a new minor version, the next minor should be released mid Feb.

@dougwilson dougwilson added this to the 4.17 milestone Jan 26, 2018
@wesleytodd
Copy link
Member

Can someone link me to a spec which defines this as valid? I cannot see anything about multiple host values being allowed in these:

https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23
https://tools.ietf.org/html/rfc7230#section-5.4

@dougwilson
Copy link
Contributor

So this is for the header X-Forwarded-Host, different from Host. Unfortunately the X-Forwarded-Host head has no specification, and is ad-hoc however these forwarding proxies are implementing them. They would always only use a single value, and suddenly with multiple reports it seems maybe there is some new forwarding software out there adding multiple values to the header.

@dsingleton
Copy link

Depending on if a security update will require a new minor version, the next minor should be released mid Feb.

Sounds more than reasonable. Thank you 😄

@wesleytodd
Copy link
Member

wesleytodd commented Jan 26, 2018

Oh, I miss-read the code change, my bad. I am still unsure what we should support here. The Forwarded header is the spec to use for the future, and technically any user could define their own value in X-Forwarded-Host. In nginx configurations, the basic way I have seen is like this:

proxy_set_header        X-Forwarded-Host   $host;

But in a configuration like this, they could as well have written:

proxy_set_header        X-Forwarded-Host   my-server.com,$host;

And without a spec, I am not sure we should be custom tailoring our support without some documentation from very popular reverse proxies like nginx or HAproxy, before doing these kind of things, because we have to support them once we add them

@dougwilson
Copy link
Contributor

I think the original issue said it was happening on Openshift in some way. But yes, perhaps at least getting a link to product documentation could be useful.

@dougwilson
Copy link
Contributor

dougwilson commented Oct 28, 2018

I am working to clean up this pull request to land in 4.17. In particular, the added test in this PR actually passed against current master without the fix, so it would seem the test doesn't actually validate the change made here. I believe that is because req.hostname doesn't include the port number, and since the test as the first element with a port number, it cuts off the rest anyway. Edit nevermind.

@dougwilson dougwilson changed the base branch from master to 4.17 October 28, 2018 21:37
@dougwilson dougwilson merged commit b93ffd4 into expressjs:4.17 Oct 28, 2018
@dougwilson
Copy link
Contributor

I just added a few more tests to the PR and merged.

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

Successfully merging this pull request may close these issues.

4 participants