¿Qué es el OWASP Cheat Sheet Series?
El OWASP Cheat Sheet Series es una colección de más de 80 guías de referencia rápida, cada una centrada en un tema de seguridad específico. Están diseñadas para que los desarrolladores implementen controles de seguridad correctamente, sin necesidad de convertirse en expertos en seguridad.
Cada cheat sheet tiene el mismo formato: contexto del problema, controls específicos con ejemplos de código, qué evitar y referencias. Son el complemento perfecto del OWASP Top 10: el Top 10 te dice qué puede salir mal, los Cheat Sheets te dicen exactamente cómo implementarlo bien.
¿Cómo usarlos en el día a día?
Añade el índice de Cheat Sheets como bookmark: cheatsheetseries.owasp.org. Cuando implementes autenticación, validación de inputs, o cualquier función con implicaciones de seguridad, consulta el cheat sheet correspondiente antes de escribir código.
Los Cheat Sheets más importantes
Autenticación y gestión de sesiones
Terminal
Authentication CS → Contraseñas, lockout, MFA, almacenamiento seguro de passwords
Password Storage CS → bcrypt/Argon2id, work factor, longitud mínima
Session Management CS → SameSite cookies, secure/HttpOnly, session fixation
JSON Web Tokens CS → Algoritmos seguros, validación de claims, rotación
OAuth 2.0 CS → Flows seguros, PKCE, state param, token storage
Password Storage — implementación correcta (Node.js)
javascriptimport bcrypt from 'bcrypt';
// Almacenamiento (registro)
const SALT_ROUNDS = 12; // work factor recomendado para 2025
const hashedPassword = await bcrypt.hash(plainPassword, SALT_ROUNDS);
// → almacenar hashedPassword en BD, nunca plainPassword
// Verificación (login)
const isValid = await bcrypt.compare(inputPassword, storedHash);
// → bcrypt ya maneja timing-safe comparison internamente
// ❌ NUNCA usar:
// MD5, SHA1, SHA256 directos (sin salt, sin work factor → crackeable con GPU)
// crypto.createHash('md5').update(pass).digest('hex')Prevención de inyecciones
Terminal
SQL Injection Prevention CS → Prepared statements, ORM seguro, least privilege BD
XSS Prevention CS → Encoding contextual, CSP, DOMPurify
LDAP Injection CS → Escapado de caracteres LDAP especiales
XML External Entity (XXE) CS → Deshabilitar DTD, parsers seguros
OS Command Injection CS → Validación de input, evitar shell=True
SSRF Prevention CS → Allowlist de URLs/IPs, deshabilitar redirects
XSS Prevention — encoding contextual
typescript// HTML Context — escapar entidades HTML
function escapeHtml(str: string): string {
return str
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
}
// DOM Context — usar DOMPurify para HTML enriquecido
import DOMPurify from 'dompurify';
const cleanHtml = DOMPurify.sanitize(userInput, {
ALLOWED_TAGS: ['b', 'i', 'em', 'strong'],
ALLOWED_ATTR: []
});
// JavaScript Context — nunca interpolar directamente
// Ejemplo: const js = JSON.stringify({ user: userName });
// ✅ Usar JSON.stringify() para datos en scripts
const safeData = JSON.stringify({ user: userName });
const js = 'var user = ' + safeData + ';';
// URL Context — encodeURIComponent para parámetros
const url = '/search?q=' + encodeURIComponent(userQuery);Criptografía y datos sensibles
Terminal
Cryptographic Storage CS → AES-256-GCM, key management, no inventar cripto
Transport Layer Security CS → TLS 1.2+ obligatorio, TLS 1.3 preferido, cipher suites
HTTP Strict Transport Sec. → HSTS preload, includeSubDomains
Secrets Management CS → Vaults, no secrets en código, rotación
Key Management CS → Ciclo de vida de claves, separación de entornos
Cryptographic Storage — AES-256-GCM (Node.js)
typescriptimport { createCipheriv, createDecipheriv, randomBytes } from 'crypto';
const ALGORITHM = 'aes-256-gcm'; // ✅ modo autenticado
function encrypt(plaintext: string, key: Buffer): { iv: string; tag: string; data: string } {
const iv = randomBytes(12); // 96 bits para GCM
const cipher = createCipheriv(ALGORITHM, key, iv);
const encrypted = Buffer.concat([cipher.update(plaintext, 'utf8'), cipher.final()]);
const tag = cipher.getAuthTag(); // authentication tag de GCM
return {
iv: iv.toString('hex'),
tag: tag.toString('hex'),
data: encrypted.toString('hex')
};
}
function decrypt(encrypted: { iv: string; tag: string; data: string }, key: Buffer): string {
const decipher = createDecipheriv(ALGORITHM, key, Buffer.from(encrypted.iv, 'hex'));
decipher.setAuthTag(Buffer.from(encrypted.tag, 'hex'));
return Buffer.concat([
decipher.update(Buffer.from(encrypted.data, 'hex')),
decipher.final()
]).toString('utf8');
}Cabeceras HTTP de seguridad
Security Headers — Next.js next.config.ts
typescript// next.config.ts — cabeceras de seguridad recomendadas por OWASP
const securityHeaders = [
{
key: 'X-DNS-Prefetch-Control',
value: 'on'
},
{
key: 'Strict-Transport-Security',
value: 'max-age=63072000; includeSubDomains; preload' // HSTS 2 años
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN' // Clickjacking protection
},
{
key: 'X-Content-Type-Options',
value: 'nosniff' // MIME sniffing protection
},
{
key: 'Referrer-Policy',
value: 'origin-when-cross-origin'
},
{
key: 'Content-Security-Policy',
value: "default-src 'self'; script-src 'self' 'nonce-{nonce}'; ..."
},
{
key: 'Permissions-Policy',
value: 'camera=(), microphone=(), geolocation=()'
}
];Infraestructura y DevSecOps
Terminal
Docker Security CS → Non-root user, read-only FS, no latest tag, seccomp
Kubernetes Security CS → Pod Security Standards, RBAC, network policies
Infrastructure as Code CS → Revisión de IaC, secrets en vault no en vars
CI/CD Security CS → Permisos mínimos, signed artifacts, OIDC vs tokens
Logging CS → Qué loguear, qué NO loguear (no log passwords/tokens)
Error Handling CS → No exponer stack traces, mensajes genéricos al usuario
Docker Security CS — Dockerfile seguro
dockerfile# ❌ Imagen insegura
FROM node:latest
COPY . /app
RUN npm install
CMD ["node", "server.js"]
# ✅ Imagen segura siguiendo Docker Security CS
FROM node:22-alpine AS builder # imagen mínima, no 'latest'
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production # solo dependencias de producción
FROM node:22-alpine AS runner
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY --chown=appuser:appgroup . .
USER appuser # no-root
EXPOSE 3000
CMD ["node", "server.js"]Índice de todos los Cheat Sheets
El índice completo y actualizado está en: cheatsheetseries.owasp.org/IndexAlphabetical.html
Terminal
Abuse Case CS HTTP Security Response Headers CS
Authentication CS IDOR Prevention CS
Authorization CS Infrastructure as Code Security CS
Bean Validation CS Injection Prevention CS
C-Based Toolchain Hardening Input Validation CS
Choosing and Using Security JSON Web Tokens CS
CI/CD Security CS Key Management CS
Clickjacking Defense CS Kubernetes Security CS
Content Security Policy CS LDAP Injection CS
Credential Stuffing CS Logging CS
Cross-Site Request Forgery Mass Assignment CS
Cryptographic Storage CS Microservices Security CS
Database Security CS Multifactor Authentication CS
Denial of Service CS NodeJS Docker Cheat Sheet
Deserialization CS OAuth 2.0 Security CS
Docker Security CS OS Command Injection CS
DOM Clobbering CS Password Storage CS
DOM-based XSS CS Pinning CS
Error Handling CS Query Parameterization CS
File Upload CS REST Assessment CS
Forgot Password CS REST Security CS
GraphQL CS SAML Security CS
HTML5 Security CS Secrets Management CS
HTTP Strict Transport Sec CS Session Management CS
...y más de 80 en total SQL Injection Prevention CS
SSRF Prevention CS
TLS Cipher String CS
Transport Layer Security CS
Unvalidated Redirects CS
User Privacy Protection CS
Virtual Patching CS
Vulnerability Disclosure CS
Web Service Security CS
XML External Entity CS
XML Security CS
XSS Prevention CS
Por Aitana Security Team