Files
nick-doc/Issues/ISSUE-081-frontend-tokens-stored-in-localstorage-xss-accessible.md
Siavash Sameni dceaf82934 audit: 2026-05-30 full-codebase audit — report, issues, docs, runbooks
Full-codebase-audit 2026-05-30 outputs:
- Audit report: 09 - Audits/Full Codebase Audit - 2026-05-30.md
- 81 issue files ISSUE-055..135 (decisions + 1 skipped no-brainer).
- Scanner docs from scratch (was zero): architecture, data model, API ref, payment
  flow, operations runbook + repo README.
- Doc-sync updates across API reference, data models, flows, design system.
- Secret Rotation Runbook (08 - Operations) for the exposed credentials.
- Reusable workflow guide (07 - Development) + .claude/workflows/full-codebase-audit.js.

Issues remain status:open intentionally — the code fixes are uncommitted-then-committed
working-tree changes per repo and aren't "resolved" until merged/deployed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 18:48:04 +04:00

41 lines
1.5 KiB
Markdown

---
issue: 081
title: "Frontend: auth tokens stored in localStorage — XSS-accessible"
severity: medium
domain: Authentication
labels: [security, frontend, session]
status: open
created: 2026-05-30
source: Full Codebase Audit 2026-05-30
---
# Frontend: auth tokens stored in localStorage — XSS-accessible
**Severity:** medium
**Domain:** Authentication
**Labels:** security, frontend, session
## Description
`src/auth/context/jwt/action.ts:100` stores access and refresh tokens in `localStorage`. Any XSS vulnerability can steal these tokens and impersonate the user. The risk is compounded by the lack of a Content-Security-Policy (see ISSUE-083).
## Options
1. Move refresh token to HttpOnly cookie, keep short-lived access token in memory — strong, but requires backend cookie + CSRF work.
2. Keep localStorage but add strict CSP + sanitization to reduce XSS surface — cheaper, weaker.
3. Full cookie-based session with `SameSite=strict` — strongest, largest change to axios/socket auth.
## Recommendation
Plan a migration to HttpOnly refresh cookie + in-memory access token, coordinated with backend. This is a large, cross-cutting change that breaks many call sites — treat as a deliberate project.
## Affected Files
- `frontend/src/auth/context/jwt/action.ts:100`
- `frontend/src/lib/axios.ts` — auth header injection
## References
- [Full Codebase Audit 2026-05-30](../09%20-%20Audits/Full%20Codebase%20Audit%20-%202026-05-30.md) — DEC-4
- [[ISSUE-083-frontend-no-content-security-policy-header-in-next-config|ISSUE-083]]