agentleFS
edjchapmanedjchapman/claude-code-config/skills/security-patterns/SKILL.md

security-patterns

Skill8 starsChanged 19 days agoMITView on GitHub

Auth, input-validation, and secrets conventions. Use when writing or reviewing authentication, authorization, middleware, routes, JWT, CSRF, or CORS code; for a full audit of pending changes use /security-review.

  • Reads credentials

9 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use security-fuzzing and security-payloads.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • EyadkellehSkill

    security-fuzzing

    Essential fuzzing payloads: SQL injection, command injection, special characters. Curated essentials for vulnerability testing.

    Also in 3 projects that use this

  • EyadkellehSkill

    security-payloads

    Essential exploitation payloads: anti-virus test files, file name exploits, malicious files. Curated for testing.

    Also in 3 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. 0 are common, 10 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 8 edited versions we read keep these.

  • 10

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use allowlists over denylists for input filtering

    line 14
  2. Distinctive:

    Always: use parameterized queries or ORM methods

    line 20
  3. Distinctive:

    Use constant-time comparison for tokens and secrets

    line 39
  4. Distinctive:

    Never store sensitive data in JWT payload (it's base64, not encrypted)

    line 46
  5. Very specific:

    Use RS256 or ES256 over HS256 for multi-service architectures

    line 48
  6. Very specific:

    Use SameSite=Lax or Strict on session cookies

    line 53
  7. Distinctive:

    Never disable CSRF protection for convenience

    line 55
  8. Distinctive:

    Check permissions on every request, not just in UI

    line 59
  9. Distinctive:

    Use role-based or attribute-based access control

    line 60
  10. Very specific:

    Verify object ownership: if obj.owner != request.user: return 403

    line 61
  11. Distinctive:

    Never hardcode secrets, API keys, or passwords in code

    line 66
  12. Distinctive:

    Use environment variables or secret managers (AWS Secrets Manager, Vault)

    line 67
  13. Very specific:

    Add .env and credential files to .gitignore

    line 68
  14. Distinctive:

    Ensure these headers are set in production:

    line 73

“Common” is measured: kept by at least 6 in 10 of the 8 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Security Patterns

Apply these security practices when writing or reviewing code in auth, middleware, and API layers.

Input Validation

  • Always validate at system boundaries (API endpoints, form handlers, message consumers)
  • Never trust client-side validation alone
  • Use allowlists over denylists for input filtering
  • Validate types, lengths, ranges, and formats
  • Sanitize HTML output to prevent XSS (use framework auto-escaping)

SQL Injection Prevention

  • Always use parameterized queries or ORM methods
  • Never construct SQL with string concatenation or f-strings
  • Django: use QuerySet methods, Q objects, or params argument for raw SQL
  • Node.js: use query builders (Knex) or ORM (Prisma, TypeORM) -- never template literals in SQL
# WRONG
User.objects.raw(f"SELECT * FROM users WHERE email = '{email}'")

# CORRECT
User.objects.raw("SELECT * FROM users WHERE email = %s", [email])
User.objects.filter(email=email)

Authentication

  • Hash passwords with bcrypt, argon2, or scrypt (never MD5/SHA alone)
  • Enforce minimum password complexity at registration
  • Rate-limit login attempts (exponential backoff or account lockout)
  • Use constant-time comparison for tokens and secrets
  • Invalidate sessions on password change

JWT / Token Security

  • Set short expiration times (15min for access tokens, days for refresh)
  • Store refresh tokens server-side (database or Redis)
  • Never store sensitive data in JWT payload (it's base64, not encrypted)
  • Validate iss, aud, and exp claims on every request
  • Use RS256 or ES256 over HS256 for multi-service architectures

CSRF Protection

  • Enable framework CSRF middleware (Django: CsrfViewMiddleware)
  • Use SameSite=Lax or Strict on session cookies
  • For SPAs: use token-based auth or double-submit cookies
  • Never disable CSRF protection for convenience

Authorization

  • Check permissions on every request, not just in UI
  • Use role-based or attribute-based access control
  • Verify object ownership: if obj.owner != request.user: return 403
  • Log authorization failures for monitoring

Secrets Management

  • Never hardcode secrets, API keys, or passwords in code
  • Use environment variables or secret managers (AWS Secrets Manager, Vault)
  • Add .env and credential files to .gitignore
  • Rotate secrets on schedule and after any suspected breach

HTTP Security Headers

Ensure these headers are set in production:

  • Strict-Transport-Security: max-age=31536000; includeSubDomains
  • Content-Security-Policy: default-src 'self'
  • X-Content-Type-Options: nosniff
  • X-Frame-Options: DENY
  • Referrer-Policy: strict-origin-when-cross-origin

Logging

  • Log authentication events (login, logout, failed attempts)
  • Log authorization failures
  • Never log passwords, tokens, API keys, or PII
  • Include request IDs for traceability

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.