Skip to content

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
View on GitHub

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-hour maxAge alongside 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 -y

Installs 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

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();
});

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

Similar to Csrf Protection

More Security