/csrf-protection
Implements CSRF protection using synchronizer tokens, double-submit cookies, and SameSite attributes. Use when securing web forms, protecting state-changing endpoints, or implementing defense-in-depth authentication.
One skill from claude-skills.
shell
$ npx -y skills add secondsky/claude-skills --skill csrf-protection --agent claude-codeInstalls just this skill. Get the whole plugin for auto-invocation.
How it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfClaude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/csrf-protection
Context preview
The summary Claude sees to decide when to auto-load this skill.
Implements CSRF protection using synchronizer tokens, double-submit cookies, and SameSite attributes. Use when securing web forms, protecting state-changing endpoints, or implementing defense-in-depth authentication.
Stats
Stars194
Forks29
LanguageTypeScript
LicenseMIT
Ships with claude-skills
SKILL.md
csrf-protection.SKILL.md
--- name: csrf-protection description: Implements CSRF protection using synchronizer tokens, double-submit cookies, and SameSite attributes. Use when securing web forms, protecting state-changing endpoints, or implementing defense-in-depth authentication. license: MIT --- # CSRF Protection Defend against Cross-Site Request Forgery attacks using multiple protection layers. ## Protection Methods | Method | How It Works | Browser Support | |--------|--------------|-----------------| | Synchronizer Token | Hidden form field validated server-side | All | | Double Submit | Cookie + header must match | All | | SameSite Cookie | Browser blocks cross-origin requests | Modern | ## Token-Based Protection (Express) ```javascript const crypto = require('crypto'); function generateToken() { return crypto.randomBytes(32).toString('hex'); } // Middleware app.use((req, res, next) => { if (!req.session.csrfToken) { req.session.csrfToken = generateToken(); } res.locals.csrfToken = req.session.csrfToken; next(); });
