token-storage-security
하는 일
이 스킬은 웹 앱이 로그인 토큰을 어떻게 저장하는지, 스크립트가 토큰을 훔칠 수 있는지 확인합니다. 로그인 시스템을 만들거나 검토하는 개발자를 위한 스킬입니다.
사용하는 경우
- ✓웹 앱이 로그인 토큰을 localStorage나 sessionStorage에 저장할 때.
- ✓웹사이트에 새 로그인 시스템을 구축할 때.
- ✓삽입된 스크립트가 로그인 토큰을 훔칠 수 있는지 보안 검토에서 물을 때.
스킬 링크
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/token-storage-security/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“우리 앱은 사용자의 로그인 토큰을 localStorage에 저장합니다. 이것이 안전한가요? 어떻게 바꿔야 하나요?”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 토큰이 어디에 저장되는지, 변경 요청이 위조로부터 보호되는지 확인합니다. 그다음 JavaScript가 읽을 수 없는 보안 쿠키로 토큰을 옮기라고 제안합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 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
자주 묻는 질문
localStorage에 토큰을 두는 것이 왜 위험한가요?
페이지의 모든 JavaScript가 읽을 수 있으므로, 삽입된 스크립트 하나가 모든 토큰을 가져갈 수 있습니다.
이 스킬은 어떤 쿠키 설정을 권장하나요?
httpOnly와 Secure를 권장하고, SameSite는 Strict나 Lax로 설정하라고 합니다.
보안 쿠키만으로 충분한가요?
아니요. 데이터를 바꾸는 요청에는 CSRF 보호라고 불리는 위조 요청 방지가 여전히 필요하다고 이 스킬은 설명합니다.
상세 정보
작성자의 원본 설명
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.
인기도
- GitHub 스타
- 75k
- 순위
- #3059
- 라이선스
- MIT
- 업데이트
- 2026. 10. 31.
댓글
- …
이 저장소의 다른 스킬
frontendchecklist
75k명령줄 도구를 사용해 380개가 넘는 규칙으로 프런트엔드 코드와 실시간 페이지를 접근성, 속도, SEO, 보안 측면에서 점검합니다.
frontend-checklist-global
75kFront-End Checklist의 386개 규칙 전체로 프런트엔드 프로젝트를 감사하고, 발견한 문제마다 구체적인 해결 방법을 제시합니다.
404-page
75k없는 페이지 화면에 도움이 되는 링크가 있고 실제 404 상태 코드를 반환하는지 확인해, 길을 잃은 방문자를 돕습니다.
about-page
75k사이트를 운영하는 사람을 설명하는 명확한 소개 페이지가 있는지 검토해, 방문자와 검색 엔진의 신뢰를 높입니다.