Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[BC BREAK][HttpFoundation] Request::setTrustedProxies() takes a new required $trustedHeaderSet argument #22238

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
Apr 3, 2017

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Apr 1, 2017

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 #21830

See http://symfony.com/blog/fixing-the-trusted-proxies-configuration-for-symfony-3-3

@nicolas-grekas nicolas-grekas added this to the 3.3 milestone Apr 1, 2017
@nicolas-grekas nicolas-grekas changed the title [BC BREAK][HttpFoundation] Request::setTrustedProxies() takes a new r… [BC BREAK][HttpFoundation] Request::setTrustedProxies() takes a new required $trustedHeaderSet argument Apr 1, 2017
@fabpot
Copy link
Member

fabpot commented Apr 1, 2017

👍

@trigger_error('The "kernel.trusted_proxies" parameter is deprecated since version 3.3 and will be removed in 4.0. Use the Request::setTrustedProxies() method in your front controller instead.', E_USER_DEPRECATED);

Request::setTrustedProxies($trustedProxies, Request::getTrustedHeaderSet());
if ($this->container->hasParameter('kernel.trusted_proxies')) {
Copy link
Member

Choose a reason for hiding this comment

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

this will break the cache:clear command in non-debug environment when upgrading, as the existing cache (used when booting the kernel) will have this parameter defined.

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@fabpot
Copy link
Member

fabpot commented Apr 3, 2017

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 72e2895 into symfony:master Apr 3, 2017
fabpot added a commit that referenced this pull request Apr 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 #21830

Commits
-------

72e2895 [BC BREAK][HttpFoundation] Request::setTrustedProxies() takes a new required $trustedHeaderSet argument
@nicolas-grekas nicolas-grekas deleted the http-trusted-header branch April 4, 2017 08:37
@fabpot fabpot mentioned this pull request May 1, 2017
ogizanagi added a commit to ogizanagi/recipes that referenced this pull request May 3, 2017
fabpot added a commit to symfony/recipes that referenced this pull request May 3, 2017
This PR was merged into the master branch.

Discussion
----------

Remove framework.trusted_proxies option

As deprecated and "removed" in symfony/symfony#21830 and symfony/symfony#22238 (BC break)

Commits
-------

2507e41 Remove framework.trusted_proxies option
@syrm
Copy link

syrm commented May 30, 2017

Very very bad decision to put a BC Break and not respecting semver.

@JuJuDropThor
Copy link

You made a BC Break, so you made a major version right ? According to the semver standard ?

http://semver.org/

MAJOR version when you make incompatible API changes,

and of course not a minor version because minor is for backwards-compatible bug fixes. According to the semver standard.

@nicolas-grekas
Copy link
Member Author

@syrm
Copy link

syrm commented May 30, 2017

You have many solution to avoid BC Break.
You can add an alert about that in https://github.com/sensiolabs/security-checker
You can add a message displayed when you use php app/console to warn you about that.
Etc, etc.

Not respecting semver is a bad thing.

@stof
Copy link
Member

stof commented May 30, 2017

@syrm the security-checker warns about using an insecure version of a library. But it won't help about building a secure version of the API

@syrm
Copy link

syrm commented May 30, 2017

It can evolve.

@Cayan
Copy link

Cayan commented Jun 2, 2017

Thank you for breaking my production, I think such I huge framework as Symfony should stick to the semver rules.

@syrm
Copy link

syrm commented Jun 2, 2017

But the worst thing is I get an official answer about that they gonna do that again in futur.

@fabpot
Copy link
Member

fabpot commented Jun 2, 2017

The rules have always been very clear and have always been part of the documentation. For security issues, we can break backward compatibility.

As for breaking BC in general, I like to think that we are doing a great job. Of course, from time to time, we might break BC by error. When it happens and when it's reported before the stable release, we fix it. Then, there are also cases where the difference between breaking BC and fixing a bug is not that clear.

It's not black and white. It's difficult. The core team spends most of its time on this topic. Happy if you can help.

@syrm
Copy link

syrm commented Jun 2, 2017

As I said, even for security reason you should NEVER do a BC break. For example this security problem is only on AWS. And you break the code for everyone one using proxy. You should have put a warning on dev bar about this security problem and let each one should do what they want.

@nicolas-grekas
Copy link
Member Author

I think you misunderstood the security issue, it's not AWS specific at all but can affect anyone using trusted proxies really.

@syrm
Copy link

syrm commented Jun 2, 2017

Only if you have bad server config

@theofidry
Copy link
Contributor

Sorry for joining the party a bit late. I understand Symfony policy about security issues and I second them. However when you have:

framework:
    trusted_proxies: ~

Which is the default in a fair number of applications, you get a hard BC break still even though there is no security threats. IMO this is being downright annoying for absolutely no reason.

@sstok
Copy link
Contributor

sstok commented Jun 3, 2017

@theofidry I a gree, when default (null) is set it should be simple ignored. Otherwise you can throw an exception as then it shouldn't go left unnoticed.

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Jun 3, 2017

Anyone who would like to give Theo's idea a try? (The config option should then be deprecated)

@theofidry
Copy link
Contributor

I just tried quickly with something like:

->arrayNode('trusted_proxies') // @deprecated in version 3.3, to be removed in 4.0
                    ->beforeNormalization()
                        ->always(function ($values) {
                            if (null === $values || array() == $values) {
                                return $this;
                            }

                            return $this->thenInvalid('The "framework.trusted_proxies" configuration key has been removed in Symfony 3.3. Use the Request::setTrustedProxies() method in your front controller instead.')
                        })
                    ->end()
                ->end()

But it didn't seem to work very well. I'm not very familiar with the config and I didn't see anything on how to create a custom validation rule here.

Unfortunately I cannot continue on this right now, might give it another try later during the week if I find some time.

@xabbuh
Copy link
Member

xabbuh commented Jun 3, 2017

Can you give #23049 a try?

@sstok
Copy link
Contributor

sstok commented Jun 3, 2017

return $this; ? 😄 you can simple return $values; 😛

@Cayan
Copy link

Cayan commented Jun 3, 2017

My main complain is because the issue simply broke with a recommended solution that could have come as a default argument.

It took me a couple of hours to first identify that the issue wasn't on my side and that after chain of dependencies it was SF's update that did it.

I wonder if there is a proper way to warn people of an incoming BC, as @syrm recommended.
It doesn't look like this security issue was so urgent as it took eight months from the report to the update.

fabpot added a commit that referenced this pull request Jun 3, 2017
…xies (xabbuh)

This PR was merged into the 3.3 branch.

Discussion
----------

[FrameworkBundle] mitigate BC break with empty trusted_proxies

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | kind of
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #22238 (comment)
| License       | MIT
| Doc PR        |

Commits
-------

ff055ef mitigate BC break with empty trusted_proxies
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this pull request Jun 3, 2017
…xies (xabbuh)

This PR was merged into the 3.3 branch.

Discussion
----------

[FrameworkBundle] mitigate BC break with empty trusted_proxies

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | kind of
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | symfony/symfony#22238 (comment)
| License       | MIT
| Doc PR        |

Commits
-------

ff055ef7f3 mitigate BC break with empty trusted_proxies
fabpot added a commit that referenced this pull request Jun 5, 2017
… BC break (nicolas-grekas)

This PR was merged into the 3.3 branch.

Discussion
----------

[HttpFoundation][FrameworkBundle] Revert "trusted proxies" BC break

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

Basically reverts #22238 + cleanups some comments + adds missing syncing logic in setTrustedHeaderName.

The reason for this proposal is that the BC break can go un-noticed until prod, *even if you have proper CI*. That's because your CI may not replicate exactly what your prod have (ie a reverse proxy), so that maybe only prod has a trusted-proxies configuration. I realized this while thinking about #23049: it made this situation even more likely, by removing an opportunity for you to notice the break before prod.

The reasons for the BC break are still valid and all of this is security-related. But the core security issue is already fixed. The remaining issue still exists (an heisenbug related to some people having both Forwarded and X-Forwarded-* set for some reason), but deprecating might still be enough.

WDYT? (I'm sure everyone is going to be happy with the BC break reversal, but I'm asking for feedback from people who actually could take the time to *understand* and *balance* the rationales here, thanks :) )

Commits
-------

2132333 [HttpFoundation][FrameworkBundle] Revert "trusted proxies" BC break
@fabpot
Copy link
Member

fabpot commented Jun 5, 2017

For the record, this has been reverted (at least the BC break) in #23067 and will be part of the upcoming 3.3.1 release.

@petereth
Copy link

petereth commented Jun 30, 2017

Hello!

i have a same error on a web server to install shopware.de

error:
Fatal error: Uncaught Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException: The request has both a trusted Forwarded header and a trusted Client IP header, conflicting with each other with regards to the originating IP addresses of the request. This is the result of a misconfiguration. You should either configure your proxy only to send one of these headers, or configure Symfony to distrust one of them. in /home/frischebry/www/vendor/symfony/http-foundation/Request.php:822 Stack trace: #0 /home/frischebry/www/vendor/symfony/http-foundation/Request.php(852): Symfony\Component\HttpFoundation\Request->getClientIps() #1 /home/frischebry/www/engine/Shopware/Kernel.php(215): Symfony\Component\HttpFoundation\Request->getClientIp() #2 /home/frischebry/www/engine/Shopware/Kernel.php(178): Shopware\Kernel->transformSymfonyRequestToEnlightRequest(Object(Symfony\Component\HttpFoundation\Request)) #3 /home/frischebry/www/vendor/symfony/http-kernel/HttpCache/HttpCache.php(491): Shopware\Kernel->handle(Object(Symfony\C in /home/frischebry/www/vendor/symfony/http-foundation/Request.php on line 822

it was the same error as this I think
https://symfony.com/doc/current/request/load_balancer_reverse_proxy.html#my-reverse-proxy-sends-x-forwarded-for-but-does-not-filter-the-forwarded-header

or how could I to an work around?
how could I fix that?

thx
Peter

@theofidry
Copy link
Contributor

@petereth it's in the issue description: https://symfony.com/blog/fixing-the-trusted-proxies-configuration-for-symfony-3-3, or alternatively you can just update (Sf 3.1.1 and 3.1.2 have already been released)

@petereth
Copy link

petereth commented Jul 3, 2017

Hi @theofidry thank you really for that help, is it possible for you that you could please help for that case to fix that I do not know where to find this on https://github.com/shopware/shopware/tree/5.2/vendor - there is a symphony tree !

thank you
Regards
Peter

markovlatkovic pushed a commit to markovlatkovic/recipes that referenced this pull request May 24, 2024
markovlatkovic pushed a commit to markovlatkovic/recipes that referenced this pull request May 24, 2024
This PR was merged into the master branch.

Discussion
----------

Remove framework.trusted_proxies option

As deprecated and "removed" in symfony/symfony#21830 and symfony/symfony#22238 (BC break)

Commits
-------

2507e41 Remove framework.trusted_proxies option
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.