2 ms·
These are all good points, but ultimately it seems like a well-configured cookie-based storage is equally secure as a similarly well-configured web storage sess
by dcosson 10y ago
These are all good points, but ultimately it seems like a well-configured cookie-based storage is equally secure as a similarly well-configured web storage session. There are more hacks required with cookies, but you hopefully only have to configure them in one place and there are libraries to help with the tricky parts like CSRF mitigation.
OTOH, there are some usability issues with web storage. Mobile safari in private mode (which can be a not-insignificant percentage of iOS traffic) doesn't support localstorage. Also, if you have any server-rendered pages, say, you have both a single-page web app and some admin pages with server-rendered html content, you need cookies anyway for the server-rendered pages (unless you want to make all your non-ajax forms to submit via ajax to use the local storage token, which is a pain because you'll end up fighting against most web frameworks and re-inventing the wheel).
Given this, my takeaway is that cookies basically cover a super-set of the scenarios that local storage tokens do, so it seems preferable to stick with cookies everywhere vs. using two separate auth flows, even though I agree that web storage is conceptually a nicer model with a smaller attack surface.
- vonklaus 10y agoI was curious about the useability. Assuming your configurations are both in perfect parity from a security standpoint, I would be curious to know how broadly available or unavail SS is. A user can turn it off (true of cookies), and iirc browsers have a shared storage max of 5mb ish but it varies from browser to browser. not sure what the wxact num is, but if is it possivlble to max this out? or is a page/domain given its own allocation? Also, is this workable on most mobile devices? it us avail in electron because its essentially a chromium wrapper i think but are there any other compatibility issues / synchronization issues where one or the other makes more sense?
- danjoc 10y ago>I agree that web storage is conceptually a nicer model with a smaller attack surface. I see the exact opposite. The attack surface provided by enabling JavaScript is far greater. Cookies work with JavaScript disabled while Web Storage does not. If one is really really paranoid, hiding behind 7 proxies, using Tor, then one has JavaScript off entirely.