agentleFS
RevealUIStudioRevealUIStudio/revskills/skills/security-hardening/SKILL.md

security-hardening

Skill2 starsChanged 52 days agoMITView on GitHub

Web application security hardening for OWASP Top 10 vulnerabilities. Use when implementing authentication, HTTP security headers, CORS, rate limiting, input validation, or reviewing code for XSS, SQL injection, CSRF, or SSRF. Covers CSP, HSTS, session cookies, bcrypt, Zod validation, and secrets management.

  • Reads credentials

25 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use incident-response, observability and 9 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.
  • 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

  • shanggqmSkill

    data-analysis

    数据分析技能,提供结构化的数据查询、统计分析和报告生成工作流。当用户需要查询数据库、进行数据统计分析、生成分析报告时使用。按规范输出原始数据、计算结果、Markdown报告和HTML可视化报告。

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

9 rules. 0 are common, 4 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 21 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 5

    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. Very specific:

    Never use origin: '*' with credentials: true

    line 39
  2. Very specific:

    Use Zod schemas — never trust typeof or manual checks

    line 86
  3. Very specific:

    Never use dangerouslySetInnerHTML without sanitization

    line 104
  4. Distinctive:

    Use CSP to prevent inline script execution

    line 106
  5. Distinctive:

    Use parameterized queries (Drizzle ORM does this automatically)

    line 122
  6. Distinctive:

    Never concatenate user input into SQL strings

    line 123
  7. Very specific:

    Use sql.placeholder() for dynamic queries

    line 124
  8. Very specific:

    Never commit .env files, API keys, or credentials

    line 136
  9. Distinctive:

    Prefer a single encrypted vault (or platform secret store) as source of truth.

    line 137

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

HTTP Security Headers

const securityHeaders = {
  'Content-Security-Policy': "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self'; connect-src 'self'; frame-ancestors 'none'",
  'X-Content-Type-Options': 'nosniff',
  'X-Frame-Options': 'DENY',
  'X-XSS-Protection': '0', // Disabled — CSP is the modern replacement
  'Referrer-Policy': 'strict-origin-when-cross-origin',
  'Permissions-Policy': 'camera=(), microphone=(), geolocation=()',
  'Strict-Transport-Security': 'max-age=63072000; includeSubDomains; preload',
};

CORS

const corsOptions = {
  origin: ['https://app.example.com'], // Never use '*' with credentials
  methods: ['GET', 'POST', 'PUT', 'DELETE'],
  credentials: true,
  maxAge: 86400,
};
  • Never use origin: '*' with credentials: true
  • Whitelist specific origins, never reflect the Origin header
  • Set maxAge to reduce preflight requests

Authentication (Session-Based)

// Session cookie settings
const sessionCookie = {
  httpOnly: true,    // No JavaScript access
  secure: true,      // HTTPS only
  sameSite: 'lax',   // CSRF protection
  maxAge: 86400,     // 24 hours
  path: '/',
};

// Password hashing (bcrypt, 12+ rounds)
import { hash, compare } from 'bcrypt';
const ROUNDS = 12;
const hashed = await hash(password, ROUNDS);
const valid = await compare(input, hashed);
  • Session-only auth (no JWT in cookies — JWTs can't be revoked)
  • bcrypt with 12+ rounds (not MD5, SHA-256, or plain text)
  • httpOnly cookies prevent XSS token theft
  • sameSite=lax prevents CSRF on state-changing requests

Input Validation

import { z } from 'zod';

const CreateUserSchema = z.object({
  email: z.string().email().max(255),
  name: z.string().min(1).max(100),
  role: z.enum(['admin', 'user']),
});

// Validate at system boundaries
export async function createUser(input: unknown) {
  const data = CreateUserSchema.parse(input); // throws on invalid
  // ... safe to use data
}
  • Validate ALL external input (user input, API requests, webhooks)
  • Use Zod schemas — never trust typeof or manual checks
  • Validate at system boundaries, trust internal code
  • Set reasonable max lengths to prevent abuse

Rate Limiting

// Per-endpoint rate limiting
const rateLimiter = {
  '/api/auth/sign-in': { windowMs: 15 * 60 * 1000, max: 10 },  // 10 per 15 min
  '/api/auth/sign-up': { windowMs: 60 * 60 * 1000, max: 5 },   // 5 per hour
  '/api/webhooks':     { windowMs: 60 * 1000, max: 100 },       // 100 per minute
  '/api/*':            { windowMs: 60 * 1000, max: 300 },        // 300 per minute (default)
};

XSS Prevention

  • Never use dangerouslySetInnerHTML without sanitization
  • Validate URLs: block javascript:, vbscript:, data: schemes
  • Use CSP to prevent inline script execution
  • Escape user content in HTML attributes
function isSafeUrl(url: string): boolean {
  try {
    const parsed = new URL(url);
    return ['http:', 'https:', 'mailto:'].includes(parsed.protocol);
  } catch {
    return false;
  }
}

SQL Injection Prevention

  • Use parameterized queries (Drizzle ORM does this automatically)
  • Never concatenate user input into SQL strings
  • Use sql.placeholder() for dynamic queries
// Safe (parameterized)
const users = await db.select().from(usersTable).where(eq(usersTable.email, userInput));

// DANGEROUS — never do this
const users = await db.execute(`SELECT * FROM users WHERE email = '${userInput}'`);

Secrets Management

  • Never commit .env files, API keys, or credentials
  • Prefer a single encrypted vault (or platform secret store) as source of truth; inject at runtime
  • RevealUI Studio / RevealFleet: secrets live in revvault (revvault run --env KEY=path -- cmd / with-secrets). Env vars are a downstream injection surface, not the store. See fleet secrets hardline. Lookup and inject: revvault-resolve.
  • Generic apps: environment variables or managed secret stores; never hardcode
  • Rotate credentials after any suspected exposure
  • Scan for secrets in CI (Gitleaks, GitHub Secret Scanning)

OWASP Top 10 Checklist

  1. Broken Access Control — enforce on every endpoint, not just UI
  2. Cryptographic Failures — bcrypt for passwords, TLS everywhere
  3. Injection — parameterized queries, input validation
  4. Insecure Design — threat model before coding
  5. Security Misconfiguration — security headers, disable debug in prod
  6. Vulnerable Components — audit dependencies, pin versions
  7. Authentication Failures — rate limit, brute force protection
  8. Data Integrity Failures — verify webhook signatures, validate JWTs
  9. Logging Failures — log auth events, don't log secrets
  10. SSRF — validate URLs, block internal networks

Skill by RevealUI Studio — the agentic business runtime.

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.