142 points · by tptacek · 16y ago · 48 comments
I still think allowing cookies to span more than one distinct domain was a mistake. If we had avoided that in the beginning, cookie scope implementations would be dead simple and not much functionality would be lost on the server side. Also, JavaScript cookie manipulation is something we could easily lose for the benefit of every user, web developer and server admin. I postulate there are very few legitimate uses for document.cookie
With more and more apps moving to pure JS / CSS/ and HTML front ends the lack of being able to manipulate cookies would kill a good deal of in app storage abilities. Eliminating useful feature to make someone else's job easier is rarely ever a good solution.
http://www.owasp.org/index.php/HttpOnly
If you are serving a cookie, and JavaScript doesn't need to be able to access it, you should set it to be HttpOnly to try and reduce the effects of an XSS.
The only other scheme I know of to defend against XSRF is to generate secret values for every request, which is not always practical.
You don't need to generate per-request tokens unless you want to; the token is simply yet another thing you stick into the session store and splash out onto the rendered page.
(Also, as my colleague Cory points out: if an attacker can influence the ACTION attribute of the form in any way, you've just coughed up your session token to an attacker in the name of blocking CSRF; is the risk worth the reward?).
What are you talking about "if an attacker can influence the ACTION attribute of the form"? If they are running JavaScript in your DOM you are already hosed, they can grab any token you put in your form. There is no sane reason for having ACTION change via request parameters: you would have bigger issues than session stealing. And in any other situation, you should be protected by the browser's cross domain restrictions. I don't understand what you are suggesting.
I don't like keeping per-request state on the server, else I would use random CSRF tokens.
* It has a simple reliable log-out button.
* It gives app developers more reliable fine-grained control over the login process because it in no way relies on browser chrome.
* It better supports advanced security and UX idioms, like signup-or-register or SMS-me-a-one-time-login.
* Virtually every web app in the world needs a session-keyed store anyways, and authentication is the easiest of the AAA problems anyhow, so building that one tiny piece into the protocol doesn't solve any problems.
* [ps]
Doubtless there are a myriad of nitpicky arguments about how HTTP Auth can be massaged to mitigate these problems, but who cares? Cookie auth works for everyone. Basic auth manifestly does not. Why would anyone want to expend major effort to take an archaic protocol and make it asymptotically as good as what every web app stack already provides?
[ps]: Cookie auth schemes can also be extended without getting Microsoft, Mozilla, Google, and Apple to agree on anything; this is the [end-to-end argument in systems design] in action.
In a browser context, most of the UI criticisms have little to do with the protocol itself and could be easily addressed if browsers would add a little more HTML + javascript API support for doing HTTP auth logins and logouts. Admittedly that looks unlikely to happen in the near future, which is a shame IMO. IIRC they were considering it at one point for HTML5.
SAML is a better auth mechanism for REST services.
What should WebDAV shares use instead? I don't think form auth really works for that.
* Browser specific UI, which leads to:
* No place to put password recovery links
* No place to put explanatory text
* No mechanism for logoutIf either (a) or (b) do not hold, Basic Auth is at least as hard as cookie auth.
HTTP Authentication comes in several flavours. I've not done it myself, but I think you can do interesting things to with Kerberos. Good for Intranet systems.
HTTP Authentication does have its places.
also: Lou Montulli did the blink tag. Hrmph!
That blog is just awesome, for what it's worth. He has yet to turn in a bad post.
On the face of it that seems the case.