-
-
Notifications
You must be signed in to change notification settings - Fork 213
Security hardening: Set secure cookie flag when using SSL #8474
Conversation
Even if a website is already accessible via HTTPS most setups provide a fallback for HTTP users to redirect to HTTPS. In this scenario Contao can leak sensible *_USER_AUTH cookies: Imagine a user is in the same network like an attacker. If the attacker manages to trick the user to access the Contao website via HTTP the attacker can capture the user's session. This commit mitigates the problem by activating the secure flag for cookies when using SSL.
@contao/developers Is this a bugfix or a new feature? |
I think this would not be fully backwards compatible. If someone actually wants to share the cookie between HTTP and HTTPS it would not work anymore. In favor of security it may be OK to break BC here. But wasn’t there an issue which prevented the use of cookie secure? @Toflar has it on his list in contao/core-bundle#574. |
Related issue: contao/core-bundle#443 |
Yes, it will break sites which serves HTTP and HTTPS at the same time. I.e. when coming from HTTPS with HTTPS-only Cookie and downgrade to HTTP then the HTTPS-only Cookie is missing and the "session" looks like a fresh session (i.e. you would have to re-login and stuff like that). I don't consider that as an issue. For me a site which allows HTTP-downgrade has an improper configuration (this site will for example also have a duplicated content problem because search engines like Google treats HTTP and HTTPS as different sites). |
@contao/developers Bug or feature? |
IMO Feature |
Feature
|
Feature but I assume an obsolete one with the auth PR by @bytehead. |
It is a feature but a very important one. That's why I already started working on it and unfortunately there are still show stoppers. See task (and prerequisite) number 5 in contao/core-bundle#574. If this blocker is out of the way we can even support both, page tree's using https and page tree's using http in the same installation. |
While porting the changes to Contao 4.3, I noticed another scenario that would break.
Since the back end is called via HTTPS, the cookies will be set with the secure flag. But since only one website is available via HTTPS, the front end user would not be logged in on the other website and the protected pages would not be indexed. |
The cookie cannot be set for a foreign domain anyway... |
That is true. |
Implemented in contao/core-bundle@05e725a. |
Even if a website is already accessible via HTTPS most setups provide a
fallback for HTTP users to redirect to HTTPS.
In this scenario Contao can leak sensible *_USER_AUTH cookies: Imagine a
user is in the same network like an attacker. If the attacker manages to
trick the user to access the Contao website via HTTP the attacker can
capture the user's session.
This commit mitigates the problem by activating the secure flag for cookies
when using SSL.
Tested against v3.5.16.