secondsky avatar

Api Security Hardening

This is a solid Express.js security middleware stack that layers Helmet, rate limiting, input validation, and XSS protection into your REST APIs. You get practical code for the usual suspects: sanitizing MongoDB queries, validating passwords with regex rules, and setting security headers like CSP and HSTS. The rate limiting examples are smart, with stricter limits on auth endpoints than general API routes. There's also a Python/FastAPI version and Nginx config tucked in the references. It won't catch everything, but it handles the OWASP basics you should already have in production and gives you a reasonable checklist to work from.

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

Install

$ npx -y skills add secondsky/claude-skills --skill api-security-hardening --agent claude-code

Installs into .claude/skills of the current project.

Files

API Security Hardening

Protect REST APIs against common vulnerabilities with multiple security layers.

Security Middleware Stack (Express)

const helmet = require('helmet');
const rateLimit = require('express-rate-limit');
const mongoSanitize = require('express-mongo-sanitize');

app.use(helmet());
app.use(mongoSanitize());
// For input sanitization, see the `xss-prevention` skill — do NOT use the
// deprecated `xss-clean` package (unmaintained since 2018; its own README
// recommends migrating off it).

app.use('/api/', rateLimit({
  windowMs: 15 * 60 * 1000,
  max: 100
}));

app.use('/api/auth/', rateLimit({
  windowMs: 15 * 60 * 1000,
  max: 5
}));

Input Validation

const { body, validationResult } = require('express-validator');
const escapeHtml = require('escape-html');

Sponsors

Details

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

More from secondsky/claude-skills

All 146
1aj-geddes avatardatabase-migration-managementaj-geddes/useful-ai-promptsManage database migrations and schema versioning. Use when planning migrations, version control, rollback strategies, or data transformations in PostgreSQL and 504skills.sh installs
2aj-geddes avatarapi-reference-documentationaj-geddes/useful-ai-promptsCreate comprehensive API reference documentation with OpenAPI/Swagger specs, REST endpoints, authentication, examples, and SDKs. Use when documenting REST APIs,499skills.sh installs
3yoanbernabeu avatarsupabase-extract-db-stringyoanbernabeu/supabase-pentest-skillsCRITICAL - Detect exposed PostgreSQL database connection strings in client-side code. Direct DB access is a P0 issue.499skills.sh installs
4next-safe-action avatarsafe-action-better-authnext-safe-action/skillsUse when adding authentication or authorization to safe actions with Better Auth -- covers betterAuth() middleware setup, typed session context (BetterAuthConte496skills.sh installs
5davila7 avatarbackend-dev-guidelinesdavila7/claude-code-templatesComprehensive backend development guide for Node.js/Express/TypeScript microservices. Use when creating routes, controllers, services, repositories, middleware,492skills.sh installs
6aj-geddes avatardatabase-indexing-strategyaj-geddes/useful-ai-promptsDesign and implement database indexing strategies. Use when creating indexes, choosing index types, or optimizing index performance in PostgreSQL and MySQL.491skills.sh installs