-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Security/Csrf] Trust "Referer" at the same level as "Origin" #59269
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
| { | ||
| $source = $request->headers->get('Origin') ?? $request->headers->get('Referer') ?? 'null'; | ||
| $target = $request->getSchemeAndHttpHost().'/'; | ||
| $source = 'null'; |
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.
why using a string containing null here instead of an actual null value ?
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.
The "null" string is a possible value of the Origin header. This saves checking for one more case.
See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Origin#description
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.
Hum, here you assume that we cannot receive Origin: null and Referer: http://not-the-same-origin.com/. From the doc it seems unlikely to expose the Referer with "privacy sensitive" origin.
Edit: the function will return false while previously that case returned null. Which is safer for this limit case.
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.
Yep, that's what we should do, isn't it?
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.
Yes;
|
Thank you @nicolas-grekas. |
As hinted by @GromNaN in symfony/demo#1542 (comment), there are proxies that mess up with the
Originheader, but forward a validRefererheader. Since both headers have the same level of trust, I'm proposing to trust them both equally. At the moment,OriginoverridesReferer. With this PR, we check both and accept if justReferermatches.