HomeCybersecurityOutput Encoding: Context-Aware XSS Defense

🔐 Output Encoding: Context-Aware XSS Defense

Pick an insertion context — HTML body, HTML attribute, JavaScript string or URL parameter — feed it a payload and compare unencoded, naive HTML-only, and context-correct output encoding side by side. See why one encoding scheme does not protect every sink.

Cybersecurity2DModerate60 FPS
output-encoding ↗ Open standalone

About This Demo

Output encoding is the standard OWASP defense against cross-site scripting: transform untrusted data so it can only ever be interpreted as inert data by the sink it lands in, never as code. The catch is that "the sink" is not one thing — an HTML body, an HTML attribute, a JavaScript string literal and a URL query parameter each have their own escaping rules, and an encoder built for one of them can be actively unsafe in another.

⚙ Under the hood

Pick one of four insertion sinks - HTML body, HTML attribute, JavaScript string, URL parameter - feed it a payload, then compare no encoding, naive HTML-only encoding and context-correct encoding side by side, with a live safe/unsafe verdict for each.

cybersecurityoutput-encodingxssowasphtml-escapingweb-security

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)