This page intentionally runs the vulnerable inspector code next to the patched one so you can fire a real cross-site-scripting payload and watch the difference. It's a self-contained sandbox — no chat, no network, no peers — so nothing you do here can reach anyone. The live app at index.html only ships the patched version.
In AESChat, the wire inspector logged every incoming packet by dropping its fields into the DOM. The iv field comes straight from the remote peer. Below is what a malicious peer could put in that field. Hit Render packet and watch the two panes.
innerHTMLtextContentIn the real app the inspector renders on every inbound packet, even with the panel closed. So the attack needs no clicks from the victim:
iv (or ciphertext/tag) is a payload like the one above.logPacket builds the row with innerHTML, the browser parses your <img>, the bogus src fails, and onerror runs your JavaScript in their page.From there, "end-to-end encrypted" is meaningless: your code is already inside the page, so it can read the AES key out of memory, grab every decrypted message, change what the victim sees, or quietly send messages as them. A realistic payload wouldn't reveal a banner — it would exfiltrate the key and stay silent.
Building a row with a template string and innerHTML is the shortest path to working UI, and it looks completely fine in a demo: you type a normal message, the inspector shows it, done. The trap is the data source — those fields arrive from an untrusted peer, not from you. Nothing in the happy path reveals it, and "please review my app for security" won't either unless someone traces where each value actually comes from.
// Vulnerable: peer data parsed as HTML
entry.innerHTML = `IV: <span class="packet-val">${packet.iv}</span>`;
// Patched: peer data can only ever be text
const val = document.createElement('span');
val.className = 'packet-val';
val.textContent = packet.iv; // never parsed as markup
The rule: untrusted data goes in with textContent / createElement, never interpolated into innerHTML. A Content-Security-Policy (finding H2) would have blocked the inline onerror too — defence in depth.