Frontend Security Checklist
On this page
Threat Model for Frontend
- Primary risks: XSS, token theft, session fixation, CSRF for cookie sessions, supply chain compromise.
- UI enforcement is not security. Server enforces authorization and validation.
- Production rule: minimize secrets and trust boundaries in the client.
Input and Output Safety
- Never render untrusted HTML. Avoid unsafe HTML injection APIs.
- Escape untrusted text by default, keep it as text, not markup.
- Sanitize only when HTML is required and document the allowed subset.
Authentication and Tokens
- Prefer HttpOnly Secure SameSite cookies for session tokens.
- If bearer tokens exist, keep them in memory and rotate frequently.
- Implement logout as server revocation plus client cleanup.
Network Controls
- Use HTTPS everywhere and enforce HSTS at the edge.
- Use CORS narrowly, never wildcard with credentials.
- Do not expose internal endpoints and debug routes in production builds.
Content Security Policy
- Deploy CSP to reduce XSS impact.
- Avoid unsafe-inline and unsafe-eval in production.
- Use nonces or hashes for required inline scripts.
Clickjacking and UI Redress
- Prevent framing with frame-ancestors in CSP or X-Frame-Options where applicable.
- Protect sensitive actions with explicit confirmations when required.
Dependencies and Supply Chain
- Lock dependencies and use automated vulnerability scanning.
- Review packages with high risk profiles and avoid unmaintained libraries.
- Build and deploy from trusted CI with signed artifacts where possible.
Operational Logging
- Log auth events: login, logout, refresh failures, permission changes.
- Log security relevant errors with build version and route context.
- Do not log secrets, tokens, or PII into client logs.
Release Gate Checklist
- No unsafe HTML injection paths without sanitization and tests.
- Token storage policy documented and enforced.
- CSP deployed and monitored for violations.
- Dependency audit passes and lockfile is stable.
- Frame protections are enabled.
- Security logs are wired to monitoring without sensitive data.