-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle] allow configuring trusted proxies using semantic configuration #37357
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
Conversation
a2f2942
to
f960619
Compare
299022a
to
1fb519f
Compare
PR is ready. |
1fb519f
to
f7dbc35
Compare
src/Symfony/Bundle/FrameworkBundle/Resources/config/services.php
Outdated
Show resolved
Hide resolved
f7dbc35
to
485acc4
Compare
485acc4
to
cc9f0ae
Compare
(rebased) |
@@ -242,6 +243,11 @@ public function load(array $configs, ContainerBuilder $container) | |||
$container->setParameter('kernel.default_locale', $config['default_locale']); | |||
$container->setParameter('kernel.error_controller', $config['error_controller']); | |||
|
|||
if (isset($config['trusted_proxies'], $config['trusted_headers'])) { | |||
$container->setParameter('kernel.trusted_proxies', $config['trusted_proxies']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we explode here instead of at runtime? We might also want to trim?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can't really if we want to accept env vars here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trim()
added, at runtime: I tried, but we don't support csv-parsed env vars in array-node definitions. I'm sure that could be done, but that'd require a lot of work on the Config component before. For now at least, we need to support string+explode.
cc9f0ae
to
4af55df
Compare
4af55df
to
af9dd52
Compare
Thank you @nicolas-grekas. |
Sorry for arriving this late to this pull request, but is this somehow related to the security issue in 3.3? I'm talking about https://symfony.com/blog/fixing-the-trusted-proxies-configuration-for-symfony-3-3 where the same parameter was removed from the configurations and now is being added back? |
This PR builds on the knowledge gathered in the blog post and the related issues you linked. It doesn't reintroduce the original issue.
|
|
You're correct. Providing extensibility here is a separate task, that'd need a use case and someone to implement it. OSS dynamics: future will tell if/why and how we should do it. |
Edit: I'm aware of how OSS works, do not need reminders, and in my last comment I did not ask you to change anything in the implementation. |
May I ask why the default is (and previously was, elsewhere) not to trust I understand that trusting this header has security implications, but if I am not misreading the change made here the prerequisite for evaluating the header is to configure a trusted proxy in the first place? And once you do that (because you have a proxy in place), wouldn't you usually want to also trust Also, on https://symfony.com/doc/master/deployment/proxies.html, the example configuration shown configures the proxy's IP address and uses |
Thank you Nicolas! Documentation has been re-arranged a bit since #20178, so I hope I did not miss anything that was more visible back then; also I followed the related doc PRs and hope I understood it all correctly. We all 💯 that we must not trust any proxy or header by default. David's intention back in #20178 was to make trusting proxies more safe by default by not having any default headers that would be trusted once you configure proxy IPs. He was referring to AWS ELBs, that (to my knowledge, up to the present day) do not set Fabien suggested not to have defaults optimized for the AWS case. I think the current documentation is mostly in line with this: It describes to either provide the IP and use The default configuration provided in the FrameworkBundle (with this PR) or Flex/recipes in 5.1 however is a bit odd, as it leans towards the AWS use case ( So, for setups with an Apache-based Reverse Proxy (my current use case) you need to explicitly configure the IP + explicitly configure For AWS ELB, you need network-level security config outside the scope of Symfony + trust all IPs. Bottom line: It seems to me the defaults
Maybe BC prevents us from changing this anyway, but what about going without trusted headers or using |
Side note: we often get security reports from ppl that missed that |
On top of the improved DX this should provide, this PR (and #37351) will allow removing the corresponding lines from
index.php
& recipes.Using values:
trusted_headers
is similar but is an array of headers to trust.