Skip to content

[HttpFoundation] Fix Request::getHost() when having several hosts in X_FORWARDED_HOST #21846

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

Merged
merged 1 commit into from
Mar 22, 2017

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Mar 3, 2017

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

The first "host" in the list provided by X_FORWARDED_HOST should be the one, not the last.
Already the case for "port" and "scheme".


$host = $elements[count($elements) - 1];
$host = $elements[0];
Copy link
Member

Choose a reason for hiding this comment

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

That's suspicious to me. Why do you think this is a bug?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because the port and scheme info are taken from the other edge, so this looks even more suspicious to me :) if the goal is to give back the user facing host, this is currently the wrong side.
I'd be happy to have eg @stof give his PV here.

@fabpot
Copy link
Member

fabpot commented Mar 22, 2017

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 9a2b2de into symfony:2.7 Mar 22, 2017
fabpot added a commit that referenced this pull request Mar 22, 2017
…l hosts in X_FORWARDED_HOST (nicolas-grekas)

This PR was merged into the 2.7 branch.

Discussion
----------

[HttpFoundation] Fix Request::getHost() when having several hosts in X_FORWARDED_HOST

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

The first "host" in the list provided by `X_FORWARDED_HOST` should be the one, not the last.
Already the case for "port" and "scheme".

Commits
-------

9a2b2de [HttpFoundation] Fix Request::getHost() when having several hosts in X_FORWARDED_HOST
@nicolas-grekas nicolas-grekas deleted the req-fix branch March 22, 2017 22:37
This was referenced Apr 4, 2017
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.

3 participants