Skip to content
Sharp

Authentication · interview question

How would you explain a significant risk of storing a JWT in localStorage in a browser context in an interview?

Multiple choiceHardchapter-17-curatedpremiumauthenticationjwt-signatures
Choose one answer
Answer and explanation

Correct answer

D. It is prone to XSS attacks.

Why

Storing JWTs in localStorage exposes them to XSS attacks, where a malicious script could access and misuse the token. Secure storage options like HttpOnly cookies can mitigate this risk.

Test yourself on Authentication

A free test with instant, explained results. No account needed.

Start free test
All Authentication questions →