-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Weird behavior when updating to 3.3.18 #28233
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
Comments
@jmartinsnexity Try locally fix from: #28144 |
Please confirm #28241 fixes your issue. |
Hello @nicolas-grekas, i'm sorry to tell that the #28241 does not fix the issue. As I couldn't reproduce it locally, I set up a new environnement on production server in order to do some debug. If the MasterRequest is GET, the subRequests are signed by HTTPS url and checked by HTTPS url : it works. When it fails, it means that in Component/HttpFoundation/Request, the function isSecure returns false. In v3.3.17, $this->getTrustedValues(self::HEADER_CLIENT_PROTO) returns ["https"]. |
@jmartinsnexity would you be able to create a small app that reproduces the issue with e.g. Symfony 2.8 or 3.4 (3.3 is not maintained anymore) when behind your varnish setup? It'd like to clone it and run it locally. Thanks. |
Alternatively, could you try reverting this patch partially and figure out if why change breaks your case? Trying to debug the internal state changes around it would be awesome if you can. |
@nicolas-grekas Let say my browser IP is 1.1.1.1. v3.3.18 headers in SubRequest : I guess the new SubRequestHandler removes the 'X_FORWARDED_PROTO' header for Cached SubRequests even if the connection is secure. I'll try to go into deeper debug to find out what lines break my case. |
When the method of the masterRequest is POST, the REMOTE_ADDR in the SubRequest is 127.0.0.1 and not the IP of the LoadBalancer. Is it possible that in SubRequestHandler line 44 "IpUtils::checkIp($remoteAddr, $trustedProxies)" considers 127.0.0.1 as unsecure, and removes X_FORWARDED_* headers on line 46 ? |
Are you sure you defined your trusted proxies correctly, ie the list contains the ip of varnish as seen from PHP? |
Can you spot any different in the incoming master request except POST? |
I'm running out of ideas so a reproducer would be very welcome. |
@nicolas-grekas I came out with a solution, let me explain, you'll know much better than me if it's good. Everything is about Symfony/Component/HttpKernel/HttpCache/SubRequestHandler.php. As mentioned earlier, i didn't understand why 127.0.0.1 is not set as trusted proxy before the handle function removes untrusted values, so I tried to pull up 5 lines (from line 79-83 to 42-46) :
Then, in the "// remove untrusted values" block, I replaced "$trustedProxies" by "Request::getTrustedProxies()", as it's been modified just before. This modification preserves the trusted "X_FORWARDED_PROTO" request header, so the signed subrequest hash is correct when checking it. Full modified handle function :
|
This patch turns 127.0.0.1 as an always trusted proxy. I'm not sure why we should do this... |
…meters (nicolas-grekas) This PR was merged into the 2.8 branch. Discussion ---------- [HttpKernel] fix forwarding trusted headers as server parameters | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #28233, #28226, #28225, #28240 | License | MIT | Doc PR | - Commits ------- 9295348 [HttpKernel] fix forwarding trusted headers as server parameters
I just merged #28241 into 3.4. Could you update to |
Thank you @nicolas-grekas, the problem is solved in latest 3.4 version ! |
Awesome, thanks for checking. |
Symfony version(s) affected: 3.3.18
Description
I have a weird behavior when updating from symfony 3.3.17 to 3.3.18 : render_esi blocks in Twig won't work (all sub-requets I guess) if the master request is POST, behind a proxy. Tricky context...
The encountered error is as Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException thrown by Symfony/Component/HttpKernel/EventListener/FragmentListener.php line 90.
It only appears in production environnement, when we hit servers through the Load Balancer.
I think this is linked to the security patch #cve-2018-14774 (https://symfony.com/blog/cve-2018-14774-possible-host-header-injection-when-using-httpcache).
As we are behind a Load Balancer, we set trusted proxies as mentioned in the doc using IP ranges, but still, subrequests result in an AccessDeniedHttpException.
How to reproduce
To reproduce the error, you need to use render_esi blocks in your template ( {{ render_esi(controller('MyAppBundle:Controller:actionName')) }} ). The page has to be the result of a POST request and the server has to be accessed via a proxy.
The text was updated successfully, but these errors were encountered: