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-code

Installs into .claude/skills of the current project.

Files

CSRF Protection

Defend against Cross-Site Request Forgery attacks using multiple protection layers.

Protection Methods

MethodHow It WorksBrowser Support
Synchronizer TokenHidden form field validated server-sideAll
Double SubmitCookie + header must matchAll
SameSite CookieBrowser blocks cross-origin requestsModern

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
1bobmatnyc avatarcelerybobmatnyc/claude-mpm-skillsDistributed task queue system for Python enabling asynchronous execution of background jobs, scheduled tasks, and workflows across multiple workers with Django,470skills.sh installs
2auth0 avatarexpress-oauth2-jwt-bearerauth0/agent-skillsUse when protecting Express or Node.js API endpoints with JWT Bearer token validation, scope-based access control, or DPoP binding. Integrates express-oauth2-jw469skills.sh installs
3syncfusion avatarsyncfusion-blazor-datagridsyncfusion/blazor-ui-components-skillsImplements the Syncfusion Blazor DataGrid (SfGrid) for efficient tabular operations such as sorting, filtering, paging, grouping, editing, aggregates, virtualiz468skills.sh installs
4aj-geddes avatarsession-managementaj-geddes/useful-ai-promptsImplement secure session management systems with JWT tokens, session storage, token refresh, logout handling, and CSRF protection. Use when managing user authen466skills.sh installs
5aj-geddes avatarspring-boot-applicationaj-geddes/useful-ai-promptsBuild enterprise Spring Boot applications with annotations, dependency injection, data persistence, REST controllers, and security. Use when developing Spring a463skills.sh installs
6aj-geddes avatarserverless-architectureaj-geddes/useful-ai-promptsDesign and implement serverless applications using AWS Lambda, Azure Functions, and GCP Cloud Functions with event-driven patterns and orchestration.461skills.sh installs