
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-codeInstalls 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
- Never trust client input - Validate and sanitize everything
- Use secure secrets - Store in Wrangler secrets, never in code
- Implement rate limiting - Protect against abuse
- Set security headers - Prevent common attacks
- 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- Bun Nextjs358
- Bun Package Manager358
- Bun Drizzle Integration353
- Bun Docker343
- Bun Runtime342
- Cloudflare Workers Testing340
- Bun Cloudflare Workers338
- Bun Test Coverage337
- Bun Http Server336
- Bun Test Mocking335
- Nuxt Seo335
- Bun Bundler334
- Bun Workers333
- Bun Shell331
- Bun React Ssr330
- Bun Tanstack Start329
- Cloudflare Workers Performance329
- Bun Hot Reloading328
- Bun Redis328
- Bun Ffi326
- Bun Jest Migration326
- Bun Websocket Server326
- Cloudflare Workers Runtime Apis326
- Swift Best Practices326