Comprehensive XSS Guide

Comprehensive XSS Guide A practitioner’s reference for Cross-Site Scripting — attack surface, context-aware payloads, filter/WAF/CSP bypass techniques, framework-specific vulnerabilities, real-world chains, and detection/prevention. Compiled from 293 research sources. Table of Contents Fundamentals Attack Surface & Entry Points Context-Aware Payloads Filter Bypass Techniques WAF Bypasses CSP Bypass Techniques Mutation XSS (mXSS) DOM Clobbering & Prototype Pollution Framework-Specific XSS AngularJS Sandbox Escapes postMessage & DOM XSS SVG, PDF & File Upload XSS Blind XSS Weaponized XSS Payloads Polyglots Real-World Exploitation Chains Tools & Automation Detection & Prevention Payload Quick Reference CVE Reference 1. Fundamentals XSS occurs when attacker-controlled input is rendered in a victim’s browser as executable code (JavaScript, or markup that leads to JavaScript execution). The victim’s browser runs the injected code with the origin’s privileges — same-origin access to cookies, DOM, API tokens, and session state. ...

April 10, 2026 · 16 min · Carl Sampson

Writing Secure Python Applications: Preventing SSRF, SQL Injection, and XSS

1. Core Security Foundations Treat all input as untrusted. Validate strictly (whitelists over blacklists), normalize before checks, and enforce types and sizes. Use framework security features instead of writing your own. Least privilege: minimize DB, filesystem, and network permissions. Secrets management: use environment variables or secret stores, never hardcode. Dependency hygiene: pin and audit dependencies with pip-audit or Safety. Secure HTTP headers: add HSTS, X-Frame-Options, CSP, and others. Logging & monitoring: log relevant events, but never credentials. Testing: integrate Bandit and Semgrep in CI. 2. Preventing SQL Injection (SQLi) Principle: Never build queries using string concatenation. ...

November 3, 2025 · Carl Sampson

Content Security Policy

Content Security Policy (CSP) is a browser security mechanism that controls which resources a web page is allowed to load. By declaring a policy via HTTP header, you tell the browser exactly which scripts, styles, images, fonts, and connections are permitted. Anything not explicitly allowed is blocked. CSP is one of the most effective defenses against Cross-Site Scripting (XSS) and data injection attacks. How CSP Works CSP is delivered as an HTTP response header: ...

February 23, 2023 · Carl Sampson