Skip to content
StackPractices

security

Practical resources about security for software engineers.

105 results

Protecting Applications and Data

Security is not a checkbox — it is a mindset. From input validation and XSS prevention to secrets management and compliance frameworks, every layer of the stack needs defensive design.

Browse recipes for implementing Content Security Policy, encrypting data at rest and in transit, managing API keys, and conducting dependency audits. Guides also cover OWASP Top 10 mitigations and secure coding practices by language.

intermediate

Implement API Rate Limiting with Redis

Protect APIs from abuse using token bucket and sliding window algorithms with Redis, including burst handling, distributed coordination, and custom headers for client feedback

intermediate

WebSocket Authentication and Security Patterns

How to authenticate WebSocket connections, implement token validation, and handle authorization for real-time messaging in production

advanced

Rate Limiting with Redis Token Bucket Algorithm

Implement a distributed token bucket rate limiter using Redis atomic operations for API throttling across multiple server instances

intermediate

Container Image Security Scanning with Trivy

Scan Docker images for vulnerabilities, misconfigurations, and secrets using Trivy, integrate scanning into CI/CD pipelines, and enforce image policies before deployment to production

intermediate

Scan Docker Images for CVEs with Trivy and Grype

Scan Docker images for vulnerabilities before deployment using Trivy and Grype. Covers CI integration, severity filtering, SBOM, and remediation.

intermediate

Docker Network Isolation and Inter-Container Security

Secure inter-container communication with custom Docker networks, network segmentation, and access control policies.

intermediate

Docker Secrets Management Without Hardcoding Credentials

Inject secrets into containers using Docker secrets, env files, and external secret managers without hardcoding them in images.

intermediate

Validate and Sanitize GraphQL Input Types Server-Side

Implement centralized input validation in GraphQL using custom validation functions, Zod schemas, and input type transforms

beginner

Secure APIs with HTTP Security Headers

How to configure essential security headers like HSTS, CSP, and X-Frame-Options to protect APIs and web applications from common attacks.

intermediate

Configure iptables Firewall Rules with Bash

Set up basic firewall rules with iptables and bash scripts

intermediate

SSH Key Management in Bash

Generate, rotate, and distribute SSH keys with bash scripts

intermediate

Container Security Scanning

Scan container images for vulnerabilities, misconfigurations, and secrets with Trivy, Clair, and Snyk before deploying to production.

beginner

Protect Web Forms Against CSRF Attacks

How to prevent Cross-Site Request Forgery attacks using synchronizer tokens, SameSite cookies, and double-submit cookie patterns.

intermediate

Data Privacy and GDPR Compliance

Implement data privacy controls, consent management, data anonymization, and GDPR-compliant data handling in web applications.

beginner

Schema-Based Data Validation with Zod in TypeScript

Validate and sanitize incoming data using Zod schemas with TypeScript inference, custom refinements, and error formatting for reliable API and form validation

intermediate

Implement Encryption at Rest for Databases and File Storage

How to encrypt sensitive data before storing it in databases, object storage, and backups using AES-256-GCM, envelope encryption, and key management services.

beginner

Escape HTML Entities

How to escape HTML entities to prevent XSS attacks in Python, Java, and JavaScript.

intermediate

HMAC Request Signing

Secure API requests with HMAC-SHA256 signatures to ensure integrity and authenticity.

intermediate

Detect Bugs in Java with SpotBugs Static Analysis

How to configure SpotBugs for Maven and Gradle, interpret bug patterns, suppress false positives, and integrate with CI/CD pipelines.

intermediate

Enforce Security Rules in Node.js with

How to configure eslint-plugin-security to detect insecure patterns in Node.js code, handle false positives, and integrate with CI/CD pipelines.

intermediate

Configure HTTP Security Headers with Helmet in Node.js

Set security HTTP headers in Express apps with Helmet — CSP, HSTS, X-Frame-Options, X-Content-Type-Options, and CORS for OWASP-compliant web security

intermediate

Implement OAuth 2.0 PKCE for Single-Page Applications

How to implement the OAuth 2.0 PKCE flow in single-page applications to securely authenticate users without exposing client secrets

intermediate

Password Hashing in Production

Securely hash and verify passwords using bcrypt, scrypt, and Argon2 with what works.

beginner

Find Security Issues in Python Code with Bandit

How to use Bandit to scan Python code for common security vulnerabilities, configure ignore lists, integrate with CI/CD, and interpret results.

intermediate

Encrypt and Decrypt Data with AES-GCM in Python

Encrypt sensitive data using AES-GCM with the cryptography library. Covers key derivation, nonce generation, authenticated encryption, and file encryption.

intermediate

Secure JWT Refresh Token Rotation with Python

Implement secure JWT access and refresh token rotation in Python with blacklist, reuse detection, and automatic access token renewal for stateless auth

intermediate

Strict Type Checking in Python with mypy

How to configure mypy strict mode for Python projects, handle common type errors, use Protocol and TypeGuard, and integrate with CI/CD.

beginner

Scan Python Packages for Known CVEs with pip-audit

How to use pip-audit to scan Python dependencies for known vulnerabilities, configure ignore lists, integrate with CI/CD, and remediate findings.

intermediate

Distributed Rate Limiting with FastAPI and Redis

Implement distributed rate limiting in FastAPI using Redis sliding window and token bucket algorithms with per-user, per-IP, and per-endpoint limits

advanced

Manage Application Secrets with HashiCorp Vault and Python

Store, retrieve, and rotate application secrets securely using HashiCorp Vault with Python hvac client, dynamic secrets, and automatic lease renewal

intermediate

Prevent SQL Injection with SQLAlchemy Parameterized Queries

Protect Python applications from SQL injection using SQLAlchemy parameterized queries, ORM models, input validation, and query inspection to ensure safe database access

intermediate

Implement Rate Limiting for APIs and Web Applications

How to protect APIs and web endpoints from abuse using token bucket, sliding window, and fixed window rate limiting strategies with Redis and in-memory implementations.

advanced

Implement Request Signing with HMAC

Secure API requests with HMAC signatures and AWS Signature v4 authentication for tamper-proof message integrity.

beginner

Sanitize User Input

How to sanitize and validate user input in Python, Java, and JavaScript to prevent injection attacks.

beginner

Security Headers

Harden web applications with HTTP security headers: CSP, HSTS, X-Frame-Options, and a thorough security header checklist.

intermediate

Prevent SQL Injection Attacks

How to write parameterized queries and use ORMs to eliminate SQL injection vulnerabilities across Python, JavaScript, and Java.

intermediate

Strict TypeScript ESLint Configuration for Production

How to configure typescript-eslint with strict rules for production TypeScript projects, handle type-aware linting, and integrate with CI/CD.

intermediate

Live Database Credentials with HashiCorp Vault

How to use HashiCorp Vault to generate short-lived database credentials, eliminating hardcoded passwords and reducing secret sprawl

intermediate

Prevent Cross-Site Scripting (XSS)

How to sanitize user input, escape output, and use Content Security Policy to prevent XSS attacks in web applications.

intermediate

LLM Guardrails Pattern

Validate LLM inputs and outputs with rules, classifiers, and content filters. Prevent prompt injection, toxic content, and data leakage before reaching users.

advanced

Multi-Tenant Data Isolation Pattern

Isolate tenant data in shared infrastructure using row-level security, schema-per-tenant, or database-per-tenant strategies. A pattern for SaaS applications.

advanced

Federated Identity Pattern

Delegate authentication to external identity providers. A pattern for integrating OAuth2, OIDC, SAML, and SSO across multiple services and organizations.

advanced

Voucher Pattern

Validate claims and delegate access using signed vouchers without exposing sensitive data. A security pattern for token-based authorization between services.

intermediate

Gatekeeper Pattern

Place a validation and security boundary at the edge of a system to inspect, sanitize, and authenticate all incoming requests before they reach internal services.

intermediate

Access Control Review Template

A template for auditing user access rights, verifying least privilege, and documenting access decisions across systems and teams.

intermediate

CI/CD Pipeline Security Template

A template for securing build and deployment pipelines against credential leaks, tampering, supply chain attacks, and unauthorized deployments.

intermediate

Compliance Gap Analysis Template

A template for mapping current security controls to compliance frameworks like SOC 2, ISO 27001, and PCI-DSS.

intermediate

Container Security Baseline Template

A baseline template for hardening container images, runtimes, and orchestration configurations across environments.

advanced

Data Breach Response Playbook

A step-by-step playbook for responding to security incidents involving unauthorized data access, from initial detection through notification and remediation.

beginner

Data Retention Policy Template

A template to define how long data is kept, when it is archived, and when it must be deleted for compliance and cost reasons.

intermediate

Dependency Vulnerability Report Template

A template for documenting security findings in dependencies, including severity, impact, and remediation steps for engineering teams.

advanced

Disaster Recovery Test Plan

A template for planning and executing disaster recovery tests including failover validation, data integrity checks, and recovery time measurement.

intermediate

Encryption Key Lifecycle Template

A template for managing the creation, distribution, rotation, and destruction of encryption keys across applications and services.

beginner

Endpoint Security Checklist Template

A checklist template for hardening laptops, workstations, and mobile devices that access corporate data and systems.

intermediate

Network Segmentation Policy Template

A template for documenting network security zones, segmentation rules, and traffic controls between environments and tenants.

intermediate

Penetration Test Scope Template

A template for defining the boundaries, targets, rules, and deliverables for a penetration testing engagement.

intermediate

RBAC Policy Template

A template for defining role-based access control policies, including roles, permissions, assignment rules, and review cadence.

intermediate

Secret Rotation Schedule Template

A template for tracking and scheduling the rotation of API keys, passwords, certificates, and other secrets across systems.

beginner

SSL Certificate Management Template

A template for tracking TLS/SSL certificate inventory, renewals, deployments, and expiration risks across domains and services.

intermediate

Third-Party Vendor Assessment Template

A structured template for evaluating the security, compliance, and operational posture of third-party vendors before onboarding or renewal.

beginner

User Access Audit Template

A template for reviewing and certifying user access rights across systems, applications, and data repositories.

intermediate

Vulnerability Scan Report Template

A template for summarizing vulnerability scan findings, including asset coverage, severity distribution, and remediation tracking.

advanced

API Authentication Design Template

Template for documenting API authentication flows and token lifecycle: auth scheme selection, token types, issuance, validation, refresh, revocation, MFA, OAuth2 flows, JWT configuration, and security best practices with code examples.

intermediate

API Security Review Template

A checklist template for reviewing API authentication, rate limiting, and OWASP compliance.

beginner

Data Classification Template

A template for classifying data as public, internal, confidential, or restricted with handling rules.

intermediate

Dependency Vulnerability Triage Template

Template for triaging CVEs by severity and impact: vulnerability scoring, exploitability assessment, blast radius analysis, fix prioritization, patch testing, and deployment procedures with Snyk, Dependabot, and OWASP Dependency-Check examples.

intermediate

Incident Response Playbook Template

A step-by-step playbook template for handling security incidents.

intermediate

OWASP Top 10 Remediation Checklist

Checklist for tracking OWASP Top 10 vulnerability remediation per application: risk assessment, fix priority, code-level remediation steps, verification testing, and compliance reporting with examples for each OWASP category.

intermediate

Penetration Test Remediation Template

A template for tracking security findings, assigning remediation owners, and validating fixes after penetration tests.

intermediate

Secrets Rotation Runbook

Runbook for rotating secrets without downtime: secret inventory, rotation schedule, zero-downtime rotation strategies, dual-key periods, automated rotation with AWS Secrets Manager and HashiCorp Vault, and emergency rotation procedures.

intermediate

Secrets Rotation Template

A template for scheduling and tracking the rotation of API keys, tokens, and certificates.

intermediate

Security Audit Checklist

A thorough checklist for conducting security audits of applications and infrastructure.

intermediate

Security Review Checklist for PRs

Checklist for security checks during pull request review: input validation, authentication, authorization, secrets, dependencies, injection, XSS, CSRF, logging, and automated tooling integration with code examples for secure patterns.

intermediate

Vendor Risk Assessment Template

A template for evaluating third-party vendor security and operational risks.

intermediate

Vulnerability Management Template

A repeatable template for tracking vulnerabilities, assigning remediation owners, defining patching timelines, and reporting security risks to stakeholders.

intermediate

Third-Party Dependency Audit Template

A template for auditing third-party dependencies: license compliance, security vulnerabilities, maintenance health, and supply chain risk.

intermediate

Penetration Test Report Template

A penetration test report template for documenting findings, risk ratings, reproduction steps, and remediation guidance for security assessments.

advanced

Complete Guide to LLM Security

Secure LLM applications in production. Covers prompt injection, jailbreaks, data leakage, OWASP Top 10 for LLMs, input validation, output filtering, rate limiting, red teaming, and building secure LLM pipelines with guardrails.

advanced

Complete Guide to GraphQL Security

Secure GraphQL APIs against introspection leaks, query depth attacks, cost-based DoS, batching abuse, and injection. Covers auth patterns, rate limiting, and production hardening.

intermediate

CI/CD Security: Harden Your Pipelines and Prevent Supply

A practical guide to securing CI/CD pipelines: secrets management, least-privilege runners, artifact signing, dependency scanning, and defending against supply chain attacks.

advanced

Complete Guide to Docker in Production

Run Docker containers in production with confidence. Covers multi-stage builds, distroless images, health checks, image scanning, resource limits, logging, secrets, multi-arch builds, and container runtime security with practical Dockerfile examples.

intermediate

Incident Response: Structured Handling for Production

A practical guide to incident response: declaring incidents, building an incident command structure, communication protocols, and reducing mean time to resolution with structured processes.

advanced

Disaster Recovery: RTO, RPO, and Resilient Recovery Runbooks

A practical guide to disaster recovery planning: defining RTO and RPO, backup strategies, multi-region failover, and building recovery runbooks that minimize downtime.

intermediate

API Security Checklist — Authentication to Encryption

A thorough security checklist for APIs: authentication, authorization, input validation, rate limiting, encryption, logging, and deployment hardening.

advanced

Complete Guide to API Security

Secure your APIs end-to-end. Covers rate limiting, authentication, input validation, CORS, SQL injection prevention, API gateway patterns, request size limits, pagination security, mass assignment, versioning, audit logging, and API security testing with practical code examples.

advanced

Complete Guide to Authentication Patterns

Implement authentication in production. Covers JWT, OAuth2, session-based auth, passkeys, MFA, refresh tokens, token rotation, RBAC, ABAC, SSO with SAML and OpenID Connect, and secure logout patterns with practical code examples.

advanced

Content Security Policy: CSP Headers, Nonces, Hashes

Master Content Security Policy: CSP directives, nonces, hashes, reporting, strict-dynamic, nonce-based CSP, hash-based CSP, and production deployment patterns for web security.

intermediate

CORS Security: Origins, Headers, Preflight, Credentials

Master CORS security: same-origin policy, CORS headers, preflight requests, credential handling, common misconfigurations, and production security patterns for web APIs.

advanced

Encryption at Rest: AES-256, KMS, Envelope Encryption

Master encryption at rest: AES-256-GCM, key management services, envelope encryption, key rotation, database encryption, field-level encryption, and production security patterns.

advanced

OAuth2 and OIDC: Authorization Code, PKCE, Token Validation

Master OAuth2 and OpenID Connect for production: authorization code flow with PKCE, token validation, refresh tokens, scopes, JWT verification, and security best practices.

advanced

Complete Guide to OWASP Top 10 2025

Mitigate each OWASP Top 10 2025 risk with practical code examples. Covers broken access control, cryptographic failures, injection, insecure design, security misconfiguration, vulnerable components, auth failures, software integrity, logging failures, and SSRF.

advanced

Complete Guide to Secrets Management

Manage application secrets securely in production. Covers HashiCorp Vault, AWS Secrets Manager, Azure Key Vault, GCP Secret Manager, Doppler, secret rotation, environment variables, zero-downtime rotation, and secrets in CI/CD pipelines with practical code examples.

advanced

Complete Guide to Supply Chain Security

Secure your software supply chain end-to-end. Covers SBOM generation, dependency scanning, Sigstore, SLSA framework, provenance attestation, package registries, typosquatting, dependency confusion, and CI/CD pipeline hardening with practical code examples.

intermediate

Complete Guide to Web Security Headers

Implement CSP, HSTS, X-Frame-Options, and secure headers. Covers content security policy, CORS, referrer policy, permissions policy, and testing with security scanners.

intermediate

GDPR Compliance — A Practical Guide for Developers

A developer-focused guide to GDPR compliance: data subject rights, lawful basis, data minimization, and technical measures for privacy by design.

intermediate

SOC 2 Compliance — Basics for Engineering Teams

A practical guide to SOC 2 Type II for developers: Trust Service Criteria, evidence collection, and building compliant systems from day one.

intermediate

Cryptography Basics — Encryption, Hashing, and Signing

A developer's guide to cryptography: symmetric and asymmetric encryption, hashing, digital signatures, and key management with practical code examples.

intermediate

OWASP Top 10: Explained with Mitigations

A developer-focused guide to the OWASP Top 10 security risks: how each vulnerability works, real-world examples, and practical mitigations for web applications.

intermediate

Secrets Management: Vault, Cloud Managers

A practical guide to secrets management: HashiCorp Vault, AWS Secrets Manager, Azure Key Vault, and GCP Secret Manager with rotation, access control, and CI/CD integration.

intermediate

Secure Coding Practices — By Language and Pattern

A practical guide to secure coding practices across languages: input validation, memory safety, authentication, and defensive patterns for Python, Java, JavaScript, and Go.

intermediate

Security Best Practices Guide

A thorough guide to application security: authentication, authorization, input validation, secrets management, and common vulnerability prevention.

intermediate

Threat Modeling — A Practical Guide for Development Teams

A step-by-step guide to threat modeling: STRIDE, attack trees, data flow diagrams, and integrating security design review into your development process.

intermediate

Web Application Security (OWASP Top 10)

A developer-focused guide to the OWASP Top 10: injection, broken access control, XSS, insecure design, and how to prevent each vulnerability with code examples.

intermediate

Webhook Security — Delivery, Verification, and Protection

A practical guide to securing webhooks: signature verification, replay attack prevention, payload encryption, and endpoint hardening for reliable delivery.

intermediate

Zero Trust Architecture — Never Trust, Always Verify

A practical guide to implementing Zero Trust architecture: identity verification, least privilege, micro-segmentation, and continuous validation for modern systems.