token-storage-security
What it does
This skill checks how a web app stores login tokens and whether scripts could steal them. It is for developers building or reviewing sign-in systems.
When to use it
- ✓When a web app stores login tokens in localStorage or sessionStorage.
- ✓When someone sets up a new sign-in system for a website.
- ✓When a security review asks whether injected scripts could steal login tokens.
Skill link
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/token-storage-security/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“My app keeps the user's login token in localStorage. Is that safe, and how should I change it?”
5 new skills a week. 1 minute to read.
How it works
The agent checks where tokens are stored and whether changing requests are protected against forgery. It suggests moving tokens into secure cookies that JavaScript cannot read.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Store authentication tokens securely
localStorage is accessible to any JavaScript running on the page. A single XSS vulnerability — including one in a third-party script — can exfiltrate all tokens silently. httpOnly cookies are completely invisible to JavaScript; even if an attacker executes arbitrary code on the page, they cannot read the cookie. This single architectural choice eliminates the most common token theft vector.
Quick Reference
- Store session tokens and JWTs in httpOnly cookies — not localStorage
- localStorage is readable by any JavaScript on the page, including injected XSS code
- Combine httpOnly with Secure and SameSite=Strict (or Lax) cookie flags
- Use short-lived access tokens and rotate refresh tokens on each use
- Protect every state-changing request with CSRF defenses, not cookie flags alone
Check
Check whether authentication tokens are stored in httpOnly cookies or in JavaScript-accessible storage like localStorage. Verify that POST, PUT, PATCH, and DELETE requests also require a CSRF token or an equivalent anti-forgery control.
Fix
Move token storage from localStorage/sessionStorage to httpOnly cookies set by the server, and ensure the cookies have Secure and SameSite flags. Add CSRF protection to every state-changing route that relies on browser-sent credentials.
Explain
Explain why localStorage is vulnerable to XSS token theft and how httpOnly cookies mitigate this attack vector.
Code Review
Review authentication flows, token storage calls, and API client code. Flag any use of localStorage.setItem, sessionStorage.setItem, or document.cookie for storing access tokens, JWTs, or session identifiers. Also flag credentialed mutations that lack a CSRF token, Origin check, or same-site enforcement.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/security/token-storage-security
FAQ
Why is localStorage risky for tokens?
Any JavaScript on the page can read it, so one injected script can take every token.
Which cookie settings does the skill recommend?
It recommends httpOnly and Secure, plus SameSite set to Strict or Lax.
Are secure cookies enough on their own?
No. The skill says requests that change data still need protection against forged requests, called CSRF protection.
Details
Original description by the author
Use when reviewing authentication implementation, setting up a new auth system, or evaluating whether the current token storage approach exposes the application to XSS-based token theft.
Popularity
- GitHub stars
- 75k
- Ranking position
- #3059
- License
- MIT
- Updated
- 10/31/2026
Comments
- …
More skills from this repository
frontendchecklist
75kChecks frontend code and live pages against 380+ rules for accessibility, speed, SEO and security, using a command-line tool.
frontend-checklist-global
75kAudits a frontend project against all 386 Front-End Checklist rules, and gives a specific fix for each issue found.
404-page
75kChecks that your missing-page screen offers helpful links and returns a real 404 status, to help lost visitors find their way.
about-page
75kReviews whether your site has a clear About page that explains who runs it, to build trust with visitors and search engines.
Similar skills
reverse-engineer-anything
422kHelps your agent look inside shipped apps and packages to explain features, compare versions, or guide a rebuild, using the REA tool.
1password
394kHelps your agent set up the 1Password CLI, sign in, and read or inject secrets without printing their values into chat.
healthcheck
394kHelps your agent audit the computer or server that runs OpenClaw for security risks, such as SSH, firewall, updates, and backups, then suggest safe fixes.