Exploiting an HTML injection with dangling markup
An HTML injection in the magic-link email allowed an attacker to inject an unclosed image tag that exfiltrated the authentication token to an attacker-controlled server when the email was opened. This could let an attacker authenticate as an administrator.
Published on vaadata.com
During a web application penetration test, we came across the following situation:
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 application inserted the user-supplied boUrl parameter into the HTML email without proper encoding, allowing HTML injection.
Impact
An attacker could steal the magic-link authentication token and use it to authenticate as an administrator, though some email clients may block automatic image loading, reducing the chance of success.
What the attacker needed
Victim opens the email; email client loads images automatically; attacker knows a valid admin email
The fix
The application should encode all special characters in HTML when user data is reused in emails, or avoid including the boUrl parameter data entirely and apply the whitelist to the whole value.
How it was found
- Send a request to the magic-link endpoint with a valid admin email and a boUrl containing an unclosed image tag pointing to an attacker-controlled server.
- The server generates an email containing the injected HTML and the authentication token.
- When the administrator opens the email, the email client tries to load the image and sends the token to the attacker's server.
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.
A magic link is a special URL sent by email that logs you in without a password. The application put part of the user's input directly into the HTML of that email without encoding it, so an attacker could add an image tag that was never closed. When the email was opened, the email client tried to load the image and sent everything after the tag, including the secret login token, to the attacker's server.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.