secondsky avatar

Cloudflare Workers Security

This handles the security fundamentals you need for Cloudflare Workers: JWT and API key authentication, input validation with Zod, rate limiting, CORS configuration, and security headers. It includes working code for verifying tokens with crypto.subtle, hashing API keys, and a practical checklist of the top 10 vulnerabilities like SQL injection, XSS, and secrets exposure. Use it when you're building an API that needs auth, debugging CORS errors, or hardening a worker against common attacks. The templates give you drop-in middleware for auth and rate limiting. Honestly, it's less about novel techniques and more about having the boilerplate done right so you don't ship something with missing headers or weak token validation.

skills.sh installs
369
GitHub stars
248
last updated
Aug 21, 2026

Install

$ npx -y skills add secondsky/claude-skills --skill cloudflare-workers-security --agent claude-code

Installs into .claude/skills of the current project.

Files

Cloudflare Workers Security

Comprehensive security patterns for protecting Workers and APIs.

Quick Security Checklist

// 1. Validate all input
const validated = schema.parse(await request.json());

// 2. Authenticate requests
const user = await verifyToken(request.headers.get('Authorization'));
if (!user) return new Response('Unauthorized', { status: 401 });

// 3. Rate limit
const limited = await rateLimiter.check(clientIP);
if (!limited.allowed) return new Response('Too Many Requests', { status: 429 });

// 4. Add security headers
response.headers.set('X-Content-Type-Options', 'nosniff');
response.headers.set('X-Frame-Options', 'DENY');

// 5. Use HTTPS-only cookies
headers.set('Set-Cookie', 'session=xxx; Secure; HttpOnly; SameSite=Strict');

Critical Rules

  1. Never trust client input - Validate and sanitize everything
  2. Use secure secrets - Store in Wrangler secrets, never in code
  3. Implement rate limiting - Protect against abuse
  4. Set security headers - Prevent common attacks
  5. Use CORS properly - Don't use * in production

Top 10 Security Errors

Sponsors

Details

Repository
github.com/secondsky/claude-skills
Categories
Backend & APIs, Security, Cloud & Infrastructure
First seen
Jun 3, 2026

More from secondsky/claude-skills

All 146
1vercel-labs avatargooglevercel-labs/emulateEmulated Google OAuth 2.0, OpenID Connect, Gmail, Calendar, and Drive for local development and testing. Use when the user needs to test Google sign-in locally,369skills.sh installs
2zzci avatarpma-bunzzci/skillsBun implementation guide for PMA-managed backend services and internal tools. Covers project layout and monorepo promotion, required quality gates, SQLite-first364skills.sh installs
3hummingbot avatarhummingbot-developerhummingbot/skillsDeveloper skill for running Hummingbot and Gateway from source, building wheel and Docker images, and testing against Hummingbot API running from source. Use th363skills.sh installs
4jezweb avatarneon-vercel-postgresjezweb/claude-skillsSet up serverless Postgres with Neon or Vercel Postgres for Cloudflare Workers/Edge. Includes connection pooling, git-like branching, and Drizzle ORM integratio363skills.sh installs
5hummingbot avatarhummingbot-heartbeathummingbot/skillsOpenClaw cron job that delivers hourly Hummingbot status updates to your chat — API health, Gateway container, active bots/controllers, executors, and portfolio361skills.sh installs
6dhruvanbhalara avatarflutter-diodhruvanbhalara/skillsImplement HTTP networking with Dio including interceptors, retry logic, and response caching. Use when building API clients, configuring authentication headers,360skills.sh installs