agentleFS
AgentJDrewAgentJDrew/claude-skill-kit/.claude/skills/security-hardening/SKILL.md

security-hardening

Skill0 starsChanged 4 months agoMITView on GitHub

Application security covering input validation, auth, headers, secrets management, and dependency auditing. Use when hardening an app, reviewing code for security issues, configuring security headers/CSP, managing secrets, or auditing dependencies before deploy.

  • Reads credentials

26 other projects use a version of this, 1 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use coordinate, incident-response and 10 more.

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.
  • swyxioSkill

    coordinate

    Coordinate focused Luna helpers for bounded work and Astra advisers for difficult design questions while doing the main work yourself.

    Also in 3 projects that use this

  • AnthropicSkill

    incident-response

    Run an incident response workflow — triage, communicate, and write postmortem. Trigger with "we have an incident", "production is down", an alert that needs severity assessment, a status update mid-incident, or when writing a blameless postmortem after resolution.

    Also in 5 projects that use this

  • OpenAISkill

    observability

    Vercel Observability expert guidance — Drains (logs, traces, speed insights, web analytics), Web Analytics, Speed Insights, runtime logs, custom events, OpenTelemetry integration, and monitoring dashboards. Use when instrumenting, debugging, or optimizing application performance and user experience on Vercel.

    Also in 4 projects that use this

  • barisariburnuSkill

    performance-optimization

    Complete performance optimization guide for Next.js applications including frontend, backend, database, caching, and general optimization strategies. Use when improving performance, reducing bundle size, optimizing queries, or implementing caching.

    Also in 4 projects that use this

  • GitHubSkill

    accessibility-audit

    Audits actual components and routes against applicable WCAG 2.2 A/AA criteria using consumer-owned design-system evidence and repository tools. Use when asked for an accessibility audit, a11y check, keyboard or focus review, contrast check, or screen-reader verification.

    Also in 3 projects that use this

  • MicrosoftSkill

    api-design

    Guide for designing and documenting RESTful APIs. Use when asked to design an API, create endpoints, or document an API.

    Also in 5 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 23 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
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Use allowlists over denylists (accept known good, reject everything else)

    line 16
  2. Distinctive:

    Never construct HTML strings with user input.

    line 24
  3. Distinctive:

    Use an ORM or query builder.

    line 44
  4. Very specific:

    Start strict, relax as needed.

    line 54
  5. Very specific:

    Use a sliding-window algorithm.

    line 70
  6. Distinctive:

    Use short expiry (15 minutes) for access tokens

    line 74
  7. Distinctive:

    Use refresh tokens (7-30 days) stored in httpOnly cookies

    line 75
  8. Distinctive:

    Never store sensitive data in JWT payload (it is base64 encoded, not encrypted)

    line 77
  9. Very specific:

    Never commit secrets to version control (use .gitignore for .env)

    line 85
  10. Distinctive:

    Use environment variables for runtime secrets

    line 86
  11. Distinctive:

    Use a secrets manager in production (AWS Secrets Manager, HashiCorp Vault, Doppler)

    line 87
  12. Very specific:

    Use different secrets per environment (dev/staging/prod)

    line 89
  13. Distinctive:

    Run dependency audits in CI on every PR.

    line 96
  14. Distinctive:

    All inputs validated with schema validation

    line 100

“Common” is measured: kept by at least 6 in 10 of the 23 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 Hardening

Long code examples for several sections live in reference.md (extract-to-reference). This file keeps the rules and the deploy checklist.

Input Validation

Validate all input at the boundary. Never trust client-side validation alone.

Rules:

  • Validate type, length, format, and range on every input
  • Use allowlists over denylists (accept known good, reject everything else)
  • Validate file uploads: check MIME type, file extension, and magic bytes
  • Limit request body size at the server/proxy level (e.g., 1MB max)

Schema-validation example (Zod, with typed safe output): see reference.md → Input Validation.

Output Encoding

Never construct HTML strings with user input. Use templating engines with auto-escaping enabled. Encode output based on context: HTML (framework auto-escaping, never dangerouslySetInnerHTML with user input), URL (encodeURIComponent), JSON (JSON.stringify). Per-context examples: see reference.md → Output Encoding.

SQL Injection Prevention

# NEVER do this
cursor.execute(f"SELECT * FROM users WHERE id = {user_id}")

# Always use parameterized queries
cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
// NEVER do this
db.query(`SELECT * FROM users WHERE email = '${email}'`);

// Always use parameterized queries
db.query("SELECT * FROM users WHERE email = $1", [email]);

Use an ORM or query builder. If writing raw SQL, always parameterize.

CSRF Protection

Generate a per-session CSRF token and validate it (timing-safe compare) on every state-changing request (POST/PUT/PATCH/DELETE); reject with 403 on mismatch. Token-generation + middleware example: see reference.md → CSRF Protection.

For APIs with token-based auth (Bearer tokens), CSRF is not needed since the token is not auto-sent by browsers.

Content Security Policy

Start strict, relax as needed. Use nonce for inline scripts instead of unsafe-inline. Report violations with the report-uri directive. Test with Content-Security-Policy-Report-Only first. Full directive set: see reference.md → Content Security Policy.

Security Headers

Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: camera=(), microphone=(), geolocation=()

Set these on every response. Use helmet (Node.js) or equivalent middleware.

Rate Limiting

Use a sliding-window algorithm. Store counters in Redis. Return 429 with a Retry-After header. Apply stricter limits to authentication endpoints (e.g. login 5/15m, register 3/1h) than to general API traffic. Per-endpoint config example: see reference.md → Rate Limiting.

JWT Best Practices

  • Use short expiry (15 minutes) for access tokens
  • Use refresh tokens (7-30 days) stored in httpOnly cookies
  • Sign with RS256 (asymmetric) for microservices, HS256 (symmetric) for monoliths
  • Never store sensitive data in JWT payload (it is base64 encoded, not encrypted)
  • Validate iss, aud, exp, and nbf claims on every request
  • Implement token revocation via a denylist or short expiry + rotation

Full verification call (algorithms, issuer, audience, clock tolerance): see reference.md → JWT Verification.

Secrets Management

  • Never commit secrets to version control (use .gitignore for .env)
  • Use environment variables for runtime secrets
  • Use a secrets manager in production (AWS Secrets Manager, HashiCorp Vault, Doppler)
  • Rotate secrets regularly (90-day maximum for API keys)
  • Use different secrets per environment (dev/staging/prod)
  • Scan for leaked secrets in CI: trufflehog, gitleaks, git-secrets

Scanning commands (gitleaks detect / gitleaks protect --staged): see reference.md → Secrets Scanning.

Dependency Auditing

Run dependency audits in CI on every PR. Block merges on critical/high vulnerabilities. Pin dependency versions. Update dependencies weekly with automated PRs (Dependabot, Renovate). Per-ecosystem commands (npm / pip-audit / govulncheck): see reference.md → Dependency Auditing.

Checklist Before Deploy

  1. All inputs validated with schema validation
  2. SQL queries parameterized
  3. Security headers configured
  4. HTTPS enforced with HSTS
  5. Secrets externalized, not in code
  6. Dependencies audited, no critical vulnerabilities
  7. Rate limiting on all public endpoints
  8. Authentication tokens expire and rotate
  9. Error messages do not leak internal details
  10. Logging captures security events without sensitive data

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.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.