Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[HttpFoundation] Add $trustedHeaderSet arg to Request::setTrustedProxies() - deprecate not setting it#21830

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:masterfromnicolas-grekas:request-forward
Mar 22, 2017

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekasnicolas-grekas commentedMar 1, 2017
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?yes
Tests pass?no tests yet
Fixed tickets-
LicenseMIT
Doc PR-

Follow up of#18688

PR adds a second$trustedHeaderSet argument toRequest::setTrustedProxies(), can be eitherRequest::HEADER_FORWARDED orRequest::HEADER_X_FORWARDED_ALL to set which header to trust from your proxies - the idea being that without this info, one will get someConflictingHeadersException, but those may be lost in the logs.

@nicolas-grekas
Copy link
MemberAuthor

PR scope now focused on adding the second argument only. Ready.

Status: needs review

* @throws \InvalidArgumentException When $trustedHeader is invalid
*/
publicstaticfunctionsetTrustedProxies(array$proxies)
publicstaticfunctionsetTrustedProxies(array$proxies/*, string $trustedHeader*/)
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the comment is a mistake ?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

it's a reminder, for it to be uncommented in 4.0, as done in such cases usually already

@nicolas-grekas
Copy link
MemberAuthor

nicolas-grekas commentedMar 11, 2017
edited
Loading

I'm working on adding a newkernel.trusted_header_set config option in fwb, and deprecate not setting it whenkernel.trusted_proxies is set.
I'm also wondering if we shouldn't plan for renaming all theRequest::HEADER_CLIENT_* toRequest::HEADER_X_FORWARDED_* to make them less critic.
Please advise @symfony/deciders, I'd appreciate some feedback on this PR.

@nicolas-grekasnicolas-grekasforce-pushed therequest-forward branch 2 times, most recently from724fb7a to1539245CompareMarch 18, 2017 17:12
@nicolas-grekasnicolas-grekas changed the title[HttpFoundation] Add $trustedHeader arg to Request::setTrustedProxies() - deprecate not setting it[HttpFoundation] Add $trustedHeaderSet arg to Request::setTrustedProxies() - deprecate not setting itMar 18, 2017
@nicolas-grekas
Copy link
MemberAuthor

nicolas-grekas commentedMar 18, 2017
edited
Loading

Status: needs review

PR ready, with more deprecations, namely:

  • Request::CLIENT_*
  • Request::get/setTrustedHeaderName()
  • framework.trusted_proxies config andkernel.trusted_proxies param

or to`Request::HEADER_X_FORWARDED_ALL` if it is using`X-Forwarded-*` headers instead.

* The`Request::setTrustedHeaderName()` and`Request::getTrustedHeaderName()` methods are deprecated,
use the RFC7239`Forwarded` header, or the`X-Forwarded-*` headers instead.
Copy link
Member

Choose a reason for hiding this comment

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

Not sure, but IIRC, it was introduced because some proxies/setups use non-standard headers.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Looking at Express, the values are hardcoded:
http://expressjs.com/en/guide/behind-proxies.html
https://github.com/expressjs/express/blob/master/lib/request.js
I guess we're safe not supporting any fancy names.

Copy link
Member

Choose a reason for hiding this comment

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

The default names are non-standard, but widely used by popular reverse proxies (like Apache mod_proxy or Amazon EC2).. So, I think we should check if this is still the case or not.

Copy link
MemberAuthor

@nicolas-grekasnicolas-grekasMar 19, 2017
edited
Loading

Choose a reason for hiding this comment

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

As far as I looked correctly, I'd rephrase this to "The default names are non-standardized" - because they are the defacto standard in fact. Can anyone find any other name in use in place ofX-Forwarded-*, with the same semantic?

Copy link
Member

Choose a reason for hiding this comment

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

Apparently, Apache mod_proxy and Amazon EC2 use different names.

*
* @param array $proxies A list of trusted proxies
* @param array $proxies A list of trusted proxies
* @param int $trustedHeaderSet A bit field of Request::HEADER_*, usually either Request::HEADER_FORWARDED or Request::HEADER_X_FORWARDED_ALL, to set which headers to trust from your proxies
Copy link
Member

Choose a reason for hiding this comment

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

I means that you can trust theForwarded and theX-Forwarded-For headers at the same time. I don't think that this is desirable.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yes, I think it's still legitimate to support that, at least for BC.
This would be really opt-in anyway, low chance anyone will do it be mistake to me.

* The`cache:clear` command should always be called with the`--no-warmup` option.
Warmup should be done via the`cache:warmup` command.

* The "framework.trusted_proxies configuration option and the corresponding "kernel.trusted_proxies" parameter have been deprecated and will be removed in 4.0. Use the Request::setTrustedProxies() method in your front controller instead.
Copy link
Member

Choose a reason for hiding this comment

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

missing '"' after 'framework.trusted_proxies'

@fabpot
Copy link
Member

👍

@fabpot
Copy link
Member

Thank you@nicolas-grekas.

@fabpotfabpot merged commitd3c9604 intosymfony:masterMar 22, 2017
fabpot added a commit that referenced this pull requestMar 22, 2017
…:setTrustedProxies() - deprecate not setting it (nicolas-grekas)This PR was merged into the 3.3-dev branch.Discussion----------[HttpFoundation] Add $trustedHeaderSet arg to Request::setTrustedProxies() - deprecate not setting it| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | yes| Tests pass?   | no tests yet| Fixed tickets | -| License       | MIT| Doc PR        | -Follow up of#18688PR adds a second `$trustedHeaderSet` argument to `Request::setTrustedProxies()`, can be either `Request::HEADER_FORWARDED` or `Request::HEADER_X_FORWARDED_ALL` to set which header to trust from your proxies - the idea being that without this info, one will get some `ConflictingHeadersException`, but those may be lost in the logs.Commits-------d3c9604 [HttpFoundation] Add $trustedHeaderSet arg to Request::setTrustedProxies() - deprecate not setting it
@nicolas-grekasnicolas-grekas deleted the request-forward branchMarch 22, 2017 22:37
@weaverryan
Copy link
Member

Don't forget about the docs please! I just opened an issue on the docs about this - our system of always making sure at least a docs issue is opened for changes is really important! It doesn't need to be a PR - we can take care of it :)

@dzuelke
Copy link
Contributor

Bit late to the game, but I'd like to point out#20178, which is related, and should maybe be addressed together with this.

TL;DR: out of the box, Symfony should not trust any headers, even when setting a trusted proxy; the list should always be opt-in, as people are vulnerable to header forgery otherwise. AWS ELBsdo not set anX-Forwarded-Host header!

Poking@fabpot and@nicolas-grekas :)

@dzuelke
Copy link
Contributor

Also seesymfony/symfony-docs#7045

fabpot added a commit that referenced this pull requestApr 3, 2017
…) takes a new required $trustedHeaderSet argument (nicolas-grekas)This PR was merged into the 3.3-dev branch.Discussion----------[BC BREAK][HttpFoundation] Request::setTrustedProxies() takes a new required $trustedHeaderSet argument| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | yes| New feature?  | yes| BC breaks?    | yes| Deprecations? | yes| Tests pass?   | yes| Fixed tickets |#20178| License       | MIT| Doc PR        | -As discussed in linked issue, and already deprecated by#21830Commits-------72e2895 [BC BREAK][HttpFoundation] Request::setTrustedProxies() takes a new required $trustedHeaderSet argument
@fabpotfabpot mentioned this pull requestMay 1, 2017
ogizanagi added a commit to ogizanagi/recipes that referenced this pull requestMay 3, 2017
fabpot added a commit to symfony/recipes that referenced this pull requestMay 3, 2017
This PR was merged into the master branch.Discussion----------Remove framework.trusted_proxies optionAs deprecated and "removed" insymfony/symfony#21830 andsymfony/symfony#22238 (BC break)Commits-------2507e41 Remove framework.trusted_proxies option
markovlatkovic pushed a commit to markovlatkovic/recipes that referenced this pull requestMay 24, 2024
markovlatkovic pushed a commit to markovlatkovic/recipes that referenced this pull requestMay 24, 2024
This PR was merged into the master branch.Discussion----------Remove framework.trusted_proxies optionAs deprecated and "removed" insymfony/symfony#21830 andsymfony/symfony#22238 (BC break)Commits-------2507e41 Remove framework.trusted_proxies option
mo-melvin77 added a commit to mo-melvin77/recipes that referenced this pull requestJun 9, 2025
mo-melvin77 added a commit to mo-melvin77/recipes that referenced this pull requestJun 9, 2025
This PR was merged into the master branch.Discussion----------Remove framework.trusted_proxies optionAs deprecated and "removed" insymfony/symfony#21830 andsymfony/symfony#22238 (BC break)Commits-------2507e41 Remove framework.trusted_proxies option
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot left review comments

+1 more reviewer

@Nek-Nek-Nek- left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

6 participants

@nicolas-grekas@fabpot@weaverryan@dzuelke@Nek-@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp