by omgitstom · 10y ago · 0 comments
But where I have more issues is that OWASP clearly advises not to use web storage for identities:
+ A single Cross Site Scripting can be used to steal all the data in these objects, so again it's recommended not to store sensitive information in local storage. + A single Cross Site Scripting can be used to load malicious data into these objects too, so don't consider objects in these to be trusted. + Pay extra attention to “localStorage.getItem” and “setItem” calls implemented in HTML5 page. It helps in detecting when developers build solutions that put sensitive information in local storage, which is a bad practice. + Do not store session identifiers in local storage as the data is always accessible by JavaScript. Cookies can mitigate this risk using the httpOnly flag.
That said as it is a wiki anyone is free to create an account and improve it :)
Your feeling is correct. Let me put it this way:
You mitigate SQL injection effectively by making sure no data (user input) can affect the code (SQL query). i.e. Prepared statements.
There is no analogous equivalent for defeating XSS. You have to escape output.
https://paragonie.com/blog/2015/06/preventing-xss-vulnerabil...
Escaping input for SQL injection "works", but has failed pretty hard in the past:
http://stackoverflow.com/a/12118602/2224584
(Character encoding, for the lose.)
By comparison, CSRF is trivial. You use a token that only the client should know, and implement a trivial challenge/response authentication layer onto your HTTP POST APIs, make sure you're using TLS, and call it a day.
`httpOnly` doesn't protect you from anything if you are using those same cookies in AJAX requests.