View Issue Details

IDProjectCategoryView StatusLast Update
2143Composrcorepublic2019-11-12 02:29
ReporterChris Graham Assigned ToChris Graham  
PrioritynormalSeverityfeature 
Status resolvedResolutionfixed 
Summary2143: Enforce correct access protocol (HTTP vs HTTPS)
DescriptionIf a base URL / page specifies HTTPS, and you access with HTTP, handle this with a redirect, just like as if you didn't use the correct URL scheme.

Also HTTPS to HTTP, just in case caching creates issues if the wrong protocol is used.
TagsGood for training, Roadmap: v11
Attach Tags
Time estimation (hours)1
Sponsorship open

Sponsor

Date Added Member Amount Sponsored

Activities

Chris Graham

2016-01-24 06:31

administrator   ~3290

This may not be a good idea. There might be different situations where you want to pick different protocols for the same page.

Needs thought.

PDStig

2016-02-07 00:55

administrator   ~3310

Good point. Maybe a disable_https_redirect (or something similar) specification in the URL in the event one does not want an HTTPS redirect?

Chris Graham

2017-05-01 15:55

administrator   ~5048

Currently we're solving this via documenting some sample redirect rules in tut_security.

Chris Graham

2018-02-14 03:18

administrator   ~5519

Implemented in v10 behind hidden 'access_protocol_redirect' option.

Chris Graham

2018-02-14 15:43

administrator   ~5524

Actually we could try and implement the redirection in a little standalone PHP file, and use an installation option rather than a hidden option. And then update the security tutorial to reference that.
The option would define a list of situations to do redirects, e.g. 'protocol,domain'.

Chris Graham

2019-02-22 21:27

administrator   ~5924

We need to consider that all these kinds of redirects we have will not work when serving from the static cache.
So .htaccess equivalents may still be needed, and we need to think how we should handle that - maybe through documentation under static caching.

Chris Graham

2019-11-12 00:24

administrator   ~6144

Note that 'Strict-Transport-Security' should not be used by Composr as it would be assuming Composr controls a whole domain (this is a domain-level upgrade signal).

Chris Graham

2019-11-12 02:29

administrator   ~6145

This is now implemented.

Complicating factors resolved as follows:
1) What if we're behind a proxy and therefore cannot detect if SSL is being used in a normal way? We respect the 'X-Forwarded-Proto' header and trust it only if we validate the proxy caller successfully.
2) What if a page needs to be accessed sometimes HTTPS and sometimes not? I don't think that's a real use case. The use case is some pages may be HTTPS and some not, as per the 'ssl' addon. We will do forwarding based on correct identifying of what the page should be, checking both the base URL and the SSL configuration for the page (if the 'ssl' addon is installed). We cannot use a URL flag, as the HTTP->HTTPS URL redirection is a security feature and we cannot trust the calling URL parameters.
3) What about the static cache? The redirection code now runs early, it is no longer in site.php. The only issue is that the SSL addon configuration cannot be respected, leading to no redirects for individually enabled SSL pages when served via static cache. This seems an insignificant corner case.
4) While 'Strict-Transport-Security' cannot be used, it is now documented that a user can enable it in their web config (including how).
5) Redirects may also happen due to CSP. This remains documented. We do not rely on it, as we should not assume every web client has CSP available (especially things like wget).

I have removed the hidden 'access_protocol_redirect' option as it is not needed, and use of that prevented us moving the redirection code out of site.php.

Issue History

Date Modified Username Field Change
2017-05-01 15:55 Chris Graham Note Added: 0005048
2017-11-26 15:18 Chris Graham Tag Attached: Can implement during live chat
2018-02-14 03:18 Chris Graham Note Added: 0005519
2018-02-14 15:43 Chris Graham Note Added: 0005524
2019-02-22 21:27 Chris Graham Note Added: 0005924
2019-06-27 19:01 Chris Graham Tag Attached: Roadmap: v11
2019-06-27 19:42 Chris Graham Tag Renamed Can implement during live chat => Good for training
2019-11-12 00:24 Chris Graham Note Added: 0006144
2019-11-12 02:29 Chris Graham Assigned To => Chris Graham
2019-11-12 02:29 Chris Graham Status Not Assigned => Resolved
2019-11-12 02:29 Chris Graham Resolution open => fixed
2019-11-12 02:29 Chris Graham Note Added: 0006145