Hacker News new | ask | show | jobs
by randomdata 2846 days ago
localStorage can be vulnerable to XSS attacks in cases where cookies are not.
2 comments

OMG, where do people get this info? It's BS.

As an attacker, if I have successfully injected my JavaScript code into your webpage, I can make HTTP requests on your server to do whatever I want with that user's account (their cookie containing their Session ID will automatically be attached to those malicious requests; so they will look like real requests from that user).

And yes, this attack also works with httpOnly cookies; I don't need to be able to read the cookie in order to use it.

The httpOnly flag is practically useless; I don't think any hacker worth their salt would want to steal session IDs for later use (session IDs and JWTs have a way of expiring quite quickly); usually with an XSS attack, you want to do the attack in-place from inside the victim's own browser.

You can put a JWT in a cookie :V