3 ms·
If tokens are automatically stored in localStorage and automatically pulled out of it, aren't you right back to being open to CSRF? That doesn't seem meaningful
by jerf 12y ago
If tokens are automatically stored in localStorage and automatically pulled out of it, aren't you right back to being open to CSRF? That doesn't seem meaningfully different than cookies.
- dmix 12y agoHow can they do that via CSRF? The attacker would need access to javascript on the victim page to have the token pulled from localStorage, append the token to the request in order to successfully submit a form. This is protected via SOP. GET requests do not return the localStorage data... nor do GET request modify any data, unless poorly programmed. Form POST requests that get submitted by an attacker are missing the token in the request, where with cookies it gets appended automatically. Token auth is vulnerable to XSS attacks, but not CSRF. So additional precautions can be added. But I do tend to agree with Egor Homakov where XSS is a serious risk to use auth token stored via httpOnly cookie: https://twitter.com/homakov/status/298744658706714624 https://twitter.com/homakov/status/298744658706714624