Pwning WebAssembly: Bypassing XSS Filters in the WASM Sandbox
A CTF write-up describes a WASM-backed chat app that stores its whole chat state in a base64-encoded URL parameter, which the frontend decodes and renders. Because the WASM sanitisation step can be bypassed, an attacker can craft a link that renders script in the victim's browser.
zoozoo-sec.github.io
Published on zoozoo-sec.github.io
Lately, I’ve been trying to level up my pwn game, so I decided to dive into WebAssembly security. Everyone hypes WASM as safe, sandboxed thing that makes running C/C++ in the browser “secure,” but the more I played with it, the more I realized there’s a lot going on under the hood that most devs don’t even think about.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the WASM sanitiser only replaces some HTML characters, so the decoded, user-controlled chat state reaches the DOM in a form that still executes script.
Impact
An attacker could get script to run in a victim's browser by sending a crafted link, though the text does not show the full exploit or confirm a flag was captured.
What the attacker needed
Victim opens a crafted link; app reachable on port 3000
How it was found
- Open the chat app and note that chat state is kept in the URL's s parameter
- Craft a URL whose s parameter holds a base64-encoded forged chat state
- Load the crafted URL so the app decodes it and rebuilds the chat
- Observe the injected content rendering in the page
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
WebAssembly (WASM) lets developers run compiled C or Rust code inside a web page at near-native speed. This app keeps its chat messages in the page address, encoded so they can be restored on reload, and it tries to clean dangerous characters before showing them. The cleaning step can be dodged, so a crafted link makes the page run the attacker's script.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.