
Security Best Practices
- 1 installs
- 404 repo stars
- Updated August 5, 2026
- aiskillstore/marketplace
security-best-practices is a skill for hardening web apps and APIs against OWASP Top 10 risks using Express.js patterns.
About
security-best-practices is a skill for implementing web application and infrastructure security. It provides Express.js patterns for HTTPS enforcement, security headers, rate limiting, input validation, SQL injection and XSS prevention, CSRF tokens, secrets management, and JWT with refresh-token rotation. A developer uses it when securing APIs or hardening a public-facing service.
- HTTPS, security headers, and rate limiting with Helmet
- Input validation, SQL injection, XSS, and CSRF prevention
- Secrets management and JWT refresh-token rotation
Security Best Practices by the numbers
- 1 all-time installs (skills.sh)
- Ranked #1,834 of 2,203 Security skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
security-best-practices capabilities & compatibility
- Capabilities
- security audit · api hardening · input validation · secrets management
- Works with
- stripe · kubernetes
- Use cases
- security audit · api development
- Pricing
- Free
What security-best-practices says it does
Handles HTTPS, CORS, XSS, SQL Injection, CSRF, rate limiting, and OWASP Top 10.
max: 5, // only 5 times per 15 minutes
npx skills add https://github.com/aiskillstore/marketplace --skill security-best-practicesAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1 |
|---|---|
| repo stars | ★ 404 |
| Last updated | August 5, 2026 |
| Repository | aiskillstore/marketplace ↗ |
What it does
Harden a web API with security headers, input validation, CSRF, and secure JWT auth.
Who is it for?
Securing public APIs with headers, validation, CSRF protection, secrets management, and JWT rotation
Skip if: Non-web infrastructure or language-agnostic-only guidance
When should I use this skill?
Securing APIs, preventing common vulnerabilities, or implementing security policies
What you get
A hardened API with enforced HTTPS, validated input, CSRF protection, and rotated tokens.
- Security middleware
- Validation schemas
- CSRF setup
By the numbers
- Auth login capped at 5 requests per 15 minutes
Files
Security Best Practices
When to use this skill
- New project: consider security from the start
- Security audit: inspect and fix vulnerabilities
- Public API: harden APIs accessible externally
- Compliance: comply with GDPR, PCI-DSS, etc.
Instructions
Step 1: Enforce HTTPS and security headers
Express.js security middleware:
import express from 'express';
import helmet from 'helmet';
import rateLimit from 'express-rate-limit';
const app = express();
// Helmet: automatically set security headers
app.use(helmet({
contentSecurityPolicy: {
directives: {
defaultSrc: ["'self'"],
scriptSrc: ["'self'", "'unsafe-inline'", "https://trusted-cdn.com"],
styleSrc: ["'self'", "'unsafe-inline'"],
imgSrc: ["'self'", "data:", "https:"],
connectSrc: ["'self'", "https://api.example.com"],
fontSrc: ["'self'", "https:", "data:"],
objectSrc: ["'none'"],
mediaSrc: ["'self'"],
frameSrc: ["'none'"],
},
},
hsts: {
maxAge: 31536000,
includeSubDomains: true,
preload: true
}
}));
// Enforce HTTPS
app.use((req, res, next) => {
if (process.env.NODE_ENV === 'production' && !req.secure) {
return res.redirect(301, `https://${req.headers.host}${req.url}`);
}
next();
});
// Rate limiting (DDoS prevention)
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // max 100 requests per IP
message: 'Too many requests from this IP, please try again later.',
standardHeaders: true,
legacyHeaders: false,
});
app.use('/api/', limiter);
// Stricter for auth endpoints
const authLimiter = rateLimit({
windowMs: 15 * 60 * 1000,
max: 5, // only 5 times per 15 minutes
skipSuccessfulRequests: true // do not count successful requests
});
app.use('/api/auth/login', authLimiter);Step 2: Input validation (SQL Injection, XSS prevention)
Joi validation:
import Joi from 'joi';
const userSchema = Joi.object({
email: Joi.string().email().required(),
password: Joi.string().min(8).pattern(/^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]/).required(),
name: Joi.string().min(2).max(50).required()
});
app.post('/api/users', async (req, res) => {
// 1. Validate input
const { error, value } = userSchema.validate(req.body);
if (error) {
return res.status(400).json({ error: error.details[0].message });
}
// 2. Prevent SQL Injection: Parameterized Queries
// ❌ Bad example
// db.query(`SELECT * FROM users WHERE email = '${email}'`);
// ✅ Good example
const user = await db.query('SELECT * FROM users WHERE email = ?', [value.email]);
// 3. Prevent XSS: Output Encoding
// React/Vue escape automatically; otherwise use a library
import DOMPurify from 'isomorphic-dompurify';
const sanitized = DOMPurify.sanitize(userInput);
res.json({ user: sanitized });
});Step 3: Prevent CSRF
CSRF Token:
import csrf from 'csurf';
import cookieParser from 'cookie-parser';
app.use(cookieParser());
// CSRF protection
const csrfProtection = csrf({ cookie: true });
// Provide CSRF token
app.get('/api/csrf-token', csrfProtection, (req, res) => {
res.json({ csrfToken: req.csrfToken() });
});
// Validate CSRF on all POST/PUT/DELETE requests
app.post('/api/*', csrfProtection, (req, res, next) => {
next();
});
// Use on the client
// fetch('/api/users', {
// method: 'POST',
// headers: {
// 'CSRF-Token': csrfToken
// },
// body: JSON.stringify(data)
// });Step 4: Manage secrets
.env (never commit):
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/mydb
# JWT
ACCESS_TOKEN_SECRET=your-super-secret-access-token-key-min-32-chars
REFRESH_TOKEN_SECRET=your-super-secret-refresh-token-key-min-32-chars
# API Keys
STRIPE_SECRET_KEY=sk_test_xxx
SENDGRID_API_KEY=SG.xxxKubernetes Secrets:
apiVersion: v1
kind: Secret
metadata:
name: myapp-secrets
type: Opaque
stringData:
database-url: postgresql://user:password@postgres:5432/mydb
jwt-secret: your-jwt-secret// Read from environment variables
const dbUrl = process.env.DATABASE_URL;
if (!dbUrl) {
throw new Error('DATABASE_URL environment variable is required');
}Step 5: Secure API authentication
JWT + Refresh Token Rotation:
// Short-lived access token (15 minutes)
const accessToken = jwt.sign({ userId }, ACCESS_SECRET, { expiresIn: '15m' });
// Long-lived refresh token (7 days), store in DB
const refreshToken = jwt.sign({ userId }, REFRESH_SECRET, { expiresIn: '7d' });
await db.refreshToken.create({
userId,
token: refreshToken,
expiresAt: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000)
});
// Refresh token rotation: re-issue on each use
app.post('/api/auth/refresh', async (req, res) => {
const { refreshToken } = req.body;
const payload = jwt.verify(refreshToken, REFRESH_SECRET);
// Invalidate existing token
await db.refreshToken.delete({ where: { token: refreshToken } });
// Issue new tokens
const newAccessToken = jwt.sign({ userId: payload.userId }, ACCESS_SECRET, { expiresIn: '15m' });
const newRefreshToken = jwt.sign({ userId: payload.userId }, REFRESH_SECRET, { expiresIn: '7d' });
await db.refreshToken.create({
userId: payload.userId,
token: newRefreshToken,
expiresAt: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000)
});
res.json({ accessToken: newAccessToken, refreshToken: newRefreshToken });
});Constraints
Required rules (MUST)
1. HTTPS Only: HTTPS required in production 2. Separate secrets: manage via environment variables; never hardcode in code 3. Input Validation: validate all user input 4. Parameterized Queries: prevent SQL Injection 5. Rate Limiting: DDoS prevention
Prohibited items (MUST NOT)
1. No eval(): code injection risk 2. No direct innerHTML: XSS risk 3. No committing secrets: never commit .env files
OWASP Top 10 checklist
- [ ] A01: Broken Access Control - RBAC, authorization checks
- [ ] A02: Cryptographic Failures - HTTPS, encryption
- [ ] A03: Injection - Parameterized Queries, Input Validation
- [ ] A04: Insecure Design - Security by Design
- [ ] A05: Security Misconfiguration - Helmet, change default passwords
- [ ] A06: Vulnerable Components - npm audit, regular updates
- [ ] A07: Authentication Failures - strong auth, MFA
- [ ] A08: Data Integrity Failures - signature validation, CSRF prevention
- [ ] A09: Logging Failures - security event logging
- [ ] A10: SSRF - validate outbound requestsBest practices
1. Principle of Least Privilege: grant minimal privileges 2. Defense in Depth: layered security 3. Security Audits: regular security reviews
References
Metadata
Version
- Current version: 1.0.0
- Last updated: 2025-01-01
- Compatible platforms: Claude, ChatGPT, Gemini
Related skills
- authentication-setup
- deployment
Tags
#security #OWASP #HTTPS #CORS #XSS #SQL-injection #CSRF #infrastructure
Examples
Example 1: Basic usage
<!-- Add example content here -->
Example 2: Advanced usage
<!-- Add advanced example content here -->
{
"schema_version": "2.0",
"meta": {
"generated_at": "2026-03-07T08:39:34.871Z",
"slug": "supercent-io-security-best-practices",
"source_url": "https://github.com/supercent-io/skills-template/tree/main/.agent-skills/security-best-practices/",
"source_ref": "main",
"model": "claude",
"analysis_version": "3.0.0",
"source_type": "community",
"content_hash": "5456c6c9511b7f2fc8317f6f0039a298fae2f1ccb41d02a9cd0e40784a7b00ce",
"tree_hash": "c0e351dbc797dedaa6a799226a8e425320a5cb6d80b7cbe869c2bd17ad50880c"
},
"skill": {
"name": "security-best-practices",
"description": "Implement security best practices for web applications and infrastructure. Use when securing APIs, preventing common vulnerabilities, or implementing security policies. Handles HTTPS, CORS, XSS, SQL Injection, CSRF, rate limiting, and OWASP Top 10.",
"summary": "Implement security best practices for web applications including HTTPS, input validation, CSRF protection, secret management, and OWASP Top 10 compliance.",
"icon": "🔒",
"version": "1.0.0",
"author": "supercent-io",
"license": "MIT",
"tags": [
"security",
"HTTPS",
"OWASP",
"web-security",
"best-practices"
],
"supported_tools": [
"claude",
"codex",
"claude-code"
],
"risk_factors": [],
"category": "security"
},
"security_audit": {
"risk_level": "safe",
"is_blocked": false,
"safe_to_publish": true,
"summary": "This skill teaches security best practices for web applications. All static analyzer findings are FALSE POSITIVES - the skill demonstrates both vulnerable patterns (to teach what to avoid) and secure patterns (as examples). The eval() reference at line 237 is in the prohibited items section teaching users not to use it. Environment variable access demonstrates proper secret management. No actual security risks present.",
"risk_factor_evidence": [],
"critical_findings": [],
"high_findings": [],
"medium_findings": [],
"low_findings": [],
"dangerous_patterns": [
{
"title": "Static Finding: eval() Usage",
"description": "eval() at line 237 is in the 'Prohibited items' section - teaching users NOT to use eval() for security reasons. Educational content, not a vulnerability.",
"locations": [
{
"file": "SKILL.md",
"line_start": 237,
"line_end": 237
}
],
"confidence": 0.95,
"confidence_reasoning": "The skill explicitly lists eval() as a prohibited item to warn users about code injection risk. This is standard security education."
},
{
"title": "Static Finding: Shell Command Detection",
"description": "Backtick detection at multiple lines - these are regex validation patterns, not shell commands. False positive from pattern matching.",
"locations": [
{
"file": "SKILL.md",
"line_start": 25,
"line_end": 280
}
],
"confidence": 0.9,
"confidence_reasoning": "The backticks in the code examples are regex patterns like /^(?=.*[A-Z)/ used for password validation, not shell execution."
},
{
"title": "Static Finding: Environment Variable Access",
"description": "process.env access detected - this is the CORRECT way to manage secrets per security best practices. The skill teaches users to use environment variables instead of hardcoding secrets.",
"locations": [
{
"file": "SKILL.md",
"line_start": 56,
"line_end": 181
}
],
"confidence": 0.95,
"confidence_reasoning": "Using environment variables for secrets is a security best practice. The skill correctly teaches this pattern."
},
{
"title": "Static Finding: Hardcoded URLs",
"description": "URLs in code examples - these are demonstration URLs for security configuration examples (CSP, HSTS, API endpoints). Not actual vulnerabilities.",
"locations": [
{
"file": "SKILL.md",
"line_start": 37,
"line_end": 266
}
],
"confidence": 0.85,
"confidence_reasoning": "URLs like https://api.example.com in CSP configuration are example domains for demonstrating security headers."
}
],
"files_scanned": 2,
"total_lines": 304,
"audit_model": "claude",
"audited_at": "2026-03-07T08:39:34.871Z",
"risk_factors": []
},
"content": {
"user_title": "Implement Security Best Practices",
"value_statement": "Protect web applications from common vulnerabilities like SQL injection, XSS, and CSRF attacks with proven security patterns and OWASP Top 10 compliance.",
"seo_keywords": [
"security best practices",
"web security",
"HTTPS configuration",
"OWASP Top 10",
"XSS prevention",
"SQL injection prevention",
"CSRF protection",
"Claude Code security",
"Codex security",
"secure API development"
],
"actual_capabilities": [
"Configure HTTPS with security headers using Helmet.js",
"Implement input validation and sanitization to prevent injection attacks",
"Set up CSRF token protection for web forms and APIs",
"Manage secrets securely using environment variables",
"Configure rate limiting to prevent DDoS attacks",
"Apply OWASP Top 10 security checklist to applications"
],
"limitations": [
"Does not provide runtime vulnerability scanning",
"Does not include automated penetration testing",
"Does not cover infrastructure-level security like firewall configuration",
"Does not provide security compliance certification"
],
"use_cases": [
{
"title": "Secure New Web Application",
"description": "Set up security middleware and headers when building a new Express.js API from scratch.",
"target_user": "Full-stack developers building new applications"
},
{
"title": "Security Audit and Remediation",
"description": "Review existing code for vulnerabilities and apply fixes following OWASP guidelines.",
"target_user": "Security engineers and developers performing code reviews"
},
{
"title": "Compliance Preparation",
"description": "Implement required security controls for GDPR, PCI-DSS, or other compliance frameworks.",
"target_user": "DevOps engineers and security compliance officers"
}
],
"prompt_templates": [
{
"title": "Basic Security Setup",
"prompt": "Add security best practices to my Express.js application. Include Helmet.js for security headers, HTTPS enforcement, and rate limiting for the API endpoints.",
"scenario": "Getting started with web application security"
},
{
"title": "Input Validation",
"prompt": "Implement input validation for user registration API endpoint. Use Joi to validate email format, password strength (minimum 8 characters with uppercase, lowercase, number, and special character), and name length.",
"scenario": "Preventing SQL injection and XSS through validation"
},
{
"title": "CSRF Protection",
"prompt": "Add CSRF protection to all POST, PUT, and DELETE endpoints in my Express API. Include a middleware that validates CSRF tokens from client requests.",
"scenario": "Protecting against cross-site request forgery"
},
{
"title": "Secure Authentication",
"prompt": "Implement JWT authentication with access tokens (15 minute expiry) and refresh token rotation. Store refresh tokens in database and rotate on each use.",
"scenario": "Implementing secure user authentication"
}
],
"output_examples": [
{
"input": "Add security middleware to my Express app",
"output": "Helmet configuration with CSP, HSTS, and X-Frame-Options headers; rate limiting middleware with 100 requests per 15 minutes; HTTPS redirect for production environment"
},
{
"input": "Validate user input for a registration form",
"output": "Joi schema with email (valid format required), password (minimum 8 chars, uppercase, lowercase, number, special char), and name (2-50 characters)"
}
],
"best_practices": [
"Always use parameterized queries instead of string concatenation to prevent SQL injection",
"Store secrets in environment variables, never hardcode credentials in source code",
"Implement defense in depth with multiple layers of security controls"
],
"anti_patterns": [
"Using eval() or similar dynamic code execution with user input",
"Directly inserting user input into HTML without sanitization (innerHTML)",
"Committing .env files or other secret files to version control"
],
"faq": [
{
"question": "What is the OWASP Top 10?",
"answer": "The OWASP Top 10 is a list of the most critical web application security risks, updated periodically. It includes vulnerabilities like injection, broken authentication, sensitive data exposure, and more."
},
{
"question": "How does Helmet.js improve security?",
"answer": "Helmet.js sets various HTTP headers that protect against common attacks like XSS, clickjacking, and MIME type sniffing. It includes CSP, HSTS, X-Frame-Options, and other security headers."
},
{
"question": "What is the difference between authentication and authorization?",
"answer": "Authentication verifies who a user is (login). Authorization determines what a user can do (permissions). Both are essential for security but serve different purposes."
},
{
"question": "How do I prevent SQL injection?",
"answer": "Use parameterized queries or prepared statements instead of concatenating user input into SQL strings. Never directly insert user input into database queries."
},
{
"question": "What is CSRF protection and why do I need it?",
"answer": "CSRF (Cross-Site Request Forgery) attacks trick users into submitting malicious requests. CSRF tokens validate that requests originate from your legitimate application."
},
{
"question": "How should I manage secrets in production?",
"answer": "Use environment variables or secrets management services like AWS Secrets Manager, HashiCorp Vault, or Kubernetes Secrets. Never commit secrets to version control."
}
]
},
"file_structure": [
{
"name": "SKILL.md",
"type": "file",
"path": "SKILL.md",
"lines": 289
},
{
"name": "SKILL.toon",
"type": "file",
"path": "SKILL.toon",
"lines": 15
}
]
}
N:security-best-practices
D:Implement security best practices for web applications and infrastructure. Use when securing APIs...
G:security HTTPS CORS XSS SQL-injection
U[4]:
**New project**: consider security from the start
**Security audit**: inspect and fix vulnerabilities
**Public API**: harden APIs accessible externally
**Compliance**: comply with GDPR, PCI-DSS, etc.
S[5]{n,action}:
1,Enforce HTTPS and security headers
2,Input validation (SQL Injection, XSS prevention)
3,Prevent CSRF
4,Manage secrets
5,Secure API authentication
Related skills
FAQ
How are auth endpoints rate-limited?
A stricter limiter caps login to 5 requests per 15 minutes and skips successful requests.
How should secrets be handled?
Store them in .env or Kubernetes Secrets, never commit them, and read them from environment variables.