Skip to content
XSS Disclosed report Intermediate

Stored XSS in posts because of absence of oembed variables values escaping

A stored cross-site scripting vulnerability existed in Discourse posts because oEmbed data fetched from a remote URL was inserted into the page without escaping. An attacker could host a malicious oEmbed endpoint and embed a link in a post, causing script execution for anyone viewing the post.

skavans Follow

Originally disclosed on HackerOne

  • Triaged in 1 hour
  • Fixed in 7 days
  • Paid in 7 days
  • Disclosed after 8 days

Hello!

Steps to reproduce:

  1. Paste this payload URL in the post: http://89.223.28.48/oembed_video.html?uncache
  2. Save the post and you will see the XSS will fire.
______________2017-01-12___22.17.11.png
______________2017-01-12___22.17.11.png From the original on HackerOne

The vulnerability exists because of absence of oembed variables values escaping. There is the oembed link in the payload page:

HTML
<link type='application/json+oembed' href='http://89.223.28.48/oembed.json'>

As you can see the onebox parser goes to this oembed URL to get the data:

64.71.168.198 - - [12/Jan/2017:19:13:52 +0000] "GET /oembed_video.html HTTP/1.1" 200 388 "-" "Ruby"
64.71.168.198 - - [12/Jan/2017:19:13:52 +0000] "GET /oembed.json HTTP/1.1" 200 389 "-" "Ruby"

The content of oembed.json is:

JSON
{
        "type": "image",
        "image": "xss",
        "description": "descr' onerror='alert(/XSS by skavans/)",
        "image_width": 1,
        "image_height": 1
}

So the unescaped data is injected in the raw HTML at this line of generic_whitelisted onebox engine that leads to XSS vulnerability.

The example post with stored XSS inside is: https://try.discourse.org/t/this-is-just-one-test/632

Please let me know if you need some extra information to locate and fix the bug.

The original report as published on HackerOne, by skavans. 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

The oEmbed response fields were inserted into raw HTML without escaping, allowing an attacker-controlled value to break out of an attribute and inject an event handler.

Impact

An attacker could run script in the browser of any user who viewed the malicious post.

What the attacker needed

Ability to create a post; attacker-controlled web page with oEmbed link; victim views the post

How it was found

  1. Paste a link to a page that advertises a malicious oEmbed endpoint into a post.
  2. Save the post, which causes the forum to fetch the oEmbed JSON.
  3. View the saved post and the injected script executes.

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 you paste a link into a post, the forum software may fetch extra information from that website to show a preview. This report shows that the forum trusted that extra information too much and put it into the page without cleaning it, so a malicious website could include code that runs in the browser of anyone who views the post.

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 skavans

View all

8 more disclosed reports, best first.

More from Discourse

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.