aidantwoods / SecureHeaders

A PHP library aiming to make the use of browser security features more accessible.
MIT License
421 stars 23 forks source link

Rethink cookie upgrades #73

Open aidantwoods opened 6 years ago

aidantwoods commented 6 years ago

In future versions we should rework how cookie upgrades are handled.

Sites which care about security related headers being reliably delivered should already be using HTTPS on all their pages – which means that HTTP cookies shouldn't be a thing. Adding Secure to all cookies seems like a pretty damn easy win. (this would replace our current approach which is only slightly better than a whitelist). For cookies that must be sent over HTTP, we can permit cookies to be manually deselected from this upgrade.

I think this approach may be valuable for all settings though: it adopts a "permissions" view of the world where everything is disallowed by default, and the developer must actively opt-in to less protection. i.e. instead of having to remember to think about "we must disallow JavaScript from accessing a cookie", developers should instead think "we should grant JavaScript access to this cookie".

My current thinking is the following:

franzliedke commented 6 years ago

This sounds very sensible. :+1:

How would you plan the upgrade path? IMO, there should be another release in version 2 that allows an opt-in to the new default behavior.

aidantwoods commented 6 years ago

Thanks :)

How would you plan the upgrade path? IMO, there should be another release in version 2 that allows an opt-in to the new default behavior.

I've marked this under the Version 3 milestone since that'll be the first place we can do this by default, but we can certainly add this as opt-in behaviour in a subsequent version 2 release too.