
Csrf Protection
Implements the three main CSRF protection patterns: synchronizer tokens, double-submit cookies, and SameSite attributes. You get Express middleware with proper timing-safe comparison, session token generation, and form integration examples. The guide walks through when to apply each method and shows the HTML side too. Covers Flask and React implementations in the references. Honestly, the best part is it doesn't just dump code at you. It explains why you need multiple layers and calls out the common mistakes like thinking auth alone protects you or storing tokens in localStorage. Solid reference when you're hardening state-changing endpoints.
- skills.sh installs
- 474
- GitHub stars
- 248
- last updated
- Aug 21, 2026
Install
$ npx -y skills add secondsky/claude-skills --skill csrf-protection --agent claude-codeInstalls into .claude/skills of the current project.
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();
});
Sponsors
Details
- Repository
- github.com/secondsky/claude-skills
- Categories
- Backend & APIs, Security
- First seen
- Jun 3, 2026
More from secondsky/claude-skills
All 146- Ml Model Training474
- Payment Gateway Integration469
- Test Quality Analysis469
- Api Reference Documentation465
- Tanstack Router461
- Systematic Debugging457
- Interaction Design456
- Mutation Testing456
- Api Error Handling455
- Internationalization I18n455
- Security Headers Configuration454
- Seo Optimizer453
- Sequential Thinking448
- Bun Sqlite442
- Websocket Implementation440
- Mobile App Debugging439
- Root Cause Tracing438
- App Store Deployment437
- Database Schema Design437
- Recommendation Engine437
- Seo Keyword Cluster Builder437
- Bun Sveltekit436
- Push Notification Setup436
- Drizzle Orm D1435