|
|
|
|
|
by BlackMonday
2733 days ago
|
|
> It's probably better than cookies. Why do you think so? I would guess it's a tradeoff about what you think is more likely to happen. XSS or CSRF. Local storage (and session storage) is vulnerable to XSS. Use a strict content security policy and escape (htmlspecialchars in php and similar functions in other languages) output to combat that. Cookies are vulnerable to CSRF but can't be read from JS if they are http only (no XSS). To combat CSRF most frameworks already have built-in csrf token support. In case of a API use a double submit cookie. Frameworks like AngularJs/Angular support that out of the box. Also use the secure flag SameSite and __Host prefix [0][1] [0] https://www.youtube.com/watch?v=2uvrGQEy8i4 [1] the slides from the video: https://www.owasp.org/images/3/32/David_Johansson-Double_Def... |
|