Csrf Protection
Layered CSRF defenses covering synchronizer tokens, double-submit cookies, and SameSite cookie attributes.
- CCM score
- 52 of 100
- skills.sh installs
- 487
- GitHub stars
- 257
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers three protection methods: synchronizer tokens, double-submit cookies, and SameSite cookie attributes, with browser support noted for each
- Includes Express middleware that generates session-bound tokens and validates them in constant time with
crypto.timingSafeEqual - Enforces SameSite-based cookie settings with
httpOnly,secure, and a one-hourmaxAgealongside token checks - Designed for web forms and state-changing endpoints, with Flask-WTF and React examples in a referenced file
Install
$ npx -y skills add secondsky/claude-skills --skill csrf-protection -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
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)
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();
});
Details
- Repository
- github.com/secondsky/claude-skills
- Categories
- Security, Backend & APIs
- First seen
- Jun 3, 2026
Questions
What does the csrf-protection skill do?
The csrf-protection skill implements CSRF protection using synchronizer tokens, double-submit cookies, and SameSite cookie attributes. It is meant for securing web forms, protecting state-changing endpoints, and adding defense-in-depth to authentication.
How do I install the csrf-protection skill?
Run npx -y skills add secondsky/claude-skills --skill csrf-protection -y inside your project. Once installed, the agent can add token validation and SameSite cookie settings to your web app.
Which skills does csrf-protection sit alongside in the Security category?
csrf-protection is in the Security category on Claude Marketplaces, alongside azure-compliance, entra-agent-id, firebase-security-rules-auditor, security-audit and cloudflare-one. It stands out by focusing on request forgery defenses for web forms and endpoints.
More from secondsky/claude-skills
All 116- Ml Model Training487
- Bun Test Basics483
- Payment Gateway Integration481
- Test Quality Analysis480
- Bun Hono Integration476
- Api Reference Documentation475
- Mutation Testing471
- Tanstack Router471
- Internationalization I18n467
- Security Headers Configuration466
- Systematic Debugging466
- Bun Package Manager465
- Interaction Design465
- Seo Optimizer465
- Api Error Handling463
- Sequential Thinking458
- Bun Nextjs452
- Websocket Implementation449
- Mobile App Debugging448
- Root Cause Tracing448
- App Store Deployment447
- Recommendation Engine447
- Seo Keyword Cluster Builder447
- Push Notification Setup446
Similar to Csrf Protection
More Securitycsrf-cross-site-request-forgeryyaklang/hack-skills4.1K installsExpert CSRF playbook covering token bypasses, SameSite edge cases, JSON and multipart CSRF, and OAuth state handling.
session-managementaj-geddes/useful-ai-prompts469 installsSecure session management with JWT tokens, refresh cycles, session storage, logout handling, and CSRF protection.
security-headers-configurationsecondsky/claude-skills466 installsConfigures HTTP security headers for XSS, clickjacking, and MIME sniffing defense with Express and Nginx examples.
oauth-implementationsecondsky/claude-skills430 installsOAuth 2.0 and OpenID Connect guide covering flow selection, Express code, and PKCE for public clients.
better-auth-security-best-practicesbetter-auth/skills52.7K installsHardening guide for Better Auth covering rate limits, secrets, CSRF, origins, sessions, cookies, and audit hooks.