This wraps your Next.js API routes with CSRF protection using HMAC-SHA256 signed tokens that are session-bound and single-use. You fetch a token from /api/csrf before making POST/PUT/DELETE requests, include it in the X-CSRF-Token header, and withCsrf() handles verification automatically. The implementation is solid: HTTP-only cookies, SameSite=Strict, and tokens that expire after one use. Honestly, CSRF protection is one of those things that's easy to skip because nothing breaks without it, but the documentation here does a good job explaining why it matters with real examples like the 2008 router hijacking attacks. Works well layered with rate limiting for things like contact forms or account changes.

skills.sh installs
206
GitHub stars
18
last updated
Aug 21, 2026

Install

$ npx -y skills add harperaa/secure-claude-skills --skill csrf-protection --agent claude-code

Installs into .claude/skills of the current project.

Files

CSRF Protection - Preventing Cross-Site Request Forgery

What CSRF Attacks Are

The Attack Scenario

Imagine you're logged into your banking app. In another tab, you visit a malicious website. That website contains hidden code that submits a form to your bank: "Transfer $10,000 to attacker's account." Because you're logged in, your browser automatically sends your session cookie, and the bank processes the transfer.

This is Cross-Site Request Forgery—tricking your browser into making requests you didn't intend.

Real-World CSRF Attacks

Router DNS Hijacking (2008): A CSRF vulnerability in several home routers allowed attackers to change router DNS settings by tricking users into visiting a malicious website. Victims lost no money but were redirected to phishing sites for months. Millions of routers were affected.

YouTube Actions (2012): YouTube had a CSRF vulnerability that allowed attackers to perform actions as other users (like, subscribe, etc.) by tricking them into visiting a crafted URL.

Why CSRF Is Still Common

Sponsors

Details

Repository
github.com/harperaa/secure-claude-skills
Categories
Backend & APIs, Security
First seen
Jun 3, 2026

More from harperaa/secure-claude-skills

All 12
1sundial-org avatarself-improvementsundial-org/awesome-openclaw-skillsCaptures learnings, errors, and corrections to enable continuous improvement. Use when: (1) A command or operation fails unexpectedly, (2) User corrects Claude 204skills.sh installs
2alpic-ai avatarmcp-app-builderalpic-ai/skybridgeGuide developers through creating and updating MCP apps. Covers the full lifecycle: brainstorming ideas against UX guidelines, bootstrapping projects, implement203skills.sh installs
3charleswiltgen avataraxiom-sqlitedatacharleswiltgen/axiomUse when working with SQLiteData @Table models, CRUD operations, query patterns, CloudKit SyncEngine setup, or batch imports. Covers model definitions, @FetchAl203skills.sh installs
4jezweb avatartesting-libraryjezweb/claude-skillsTest React components with Testing Library patterns. Covers queries (getBy/findBy/queryBy), user-event interactions, async testing (findBy vs waitFor), accessib203skills.sh installs
5davila7 avataropentrons-integrationdavila7/claude-code-templatesLab automation platform for Flex/OT-2 robots. Write Protocol API v2 protocols, liquid handling, hardware modules (heater-shaker, thermocycler), labware manageme202skills.sh installs
6josiahsiegel avatartailwindcss-pluginsjosiahsiegel/claude-plugin-marketplaceTailwind CSS plugins — official plugins and custom plugin development. PROACTIVELY activate for: (1) @tailwindcss/typography (prose), (2) @tailwindcss/forms, (3202skills.sh installs