Authentication Token Stored in localStorage
The web app stored a reusable bearer authentication token in localStorage, which any JavaScript running on the page can read. An attacker who can inject script (via XSS or a malicious extension) could steal the token and make authenticated API calls as the victim.
Published on medium.com
Storing a valid authentication bearer token in localStorage looks convenient for frontend developers — but it’s a serious security anti-pattern. I’ll explain what the risk is, why it matters, how you can safely demonstrate the issue to a vendor, and how developers should fix it.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the application stored a reusable bearer token in client-side localStorage instead of an HTTP-only cookie, making it accessible to any JavaScript on the page.
Impact
An attacker with the token could make authenticated API calls as the victim, view, modify or delete data, and if tokens are long-lived or not rotated, continue using them for extended periods; severity depends on token lifetime and scope.
What the attacker needed
A free account; ability to run JavaScript on the page (XSS or extension)
The fix
Sensitive tokens should not be stored in client-accessible storage; use HTTP-only cookies, short-lived tokens, and refresh-rotation instead.
How it was found
- Log in to the application.
- Open Developer Tools and go to Application, then Local Storage.
- Copy the User key's value and paste it into a text editor.
- Find the token in the text and copy it.
- Send an API request to a user endpoint with the token in the Authorization header.
- Observe that the response returns valid user data, confirming the token is valid and reusable.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
When you log in, the site gives your browser a secret token that proves who you are. This site saved that token in a place called localStorage, which any script on the page can read. If an attacker can get a script to run on the page, they can copy the token and use it to act as you.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.