Skip to content
XSS Disclosed report Intermediate CVE-2018-16477

XSS by MathML at Active Storage

Active Storage's list of binary formats did not include application/mathml+xml, so a file uploaded with the .mml extension was served as MathML rather than as a download. An attacker could upload a MathML file containing a javascript link and get a Firefox user to click it, running script in the site's origin.

ooooooo_q Follow

Originally disclosed on HackerOne

  • Triaged in 25 days
  • Disclosed after 2.6 years

In Active Storage, formats treated as binary have been confirmed, It does not contain application/mathml+xml.

https://github.com/rails/rails/commit/d40284b1a44773b03d78ca67a888b94fd330d1b1

In Marcel::MimeType.for, if content-type can not be determined with magic byte, since it is determined using the extension, uploading the file with .mml will be judged as application/mathml+xml.

Ruby
#https://github.com/minad/mimemagic/blob/master/lib/mimemagic/tables.rb#L387
    'mml' => 'application/mathml+xml',

I confirmed that MathML XSS is executable in Mac Firefox 63. (https://html5sec.org/#130)

XML
<math xmlns="http://www.w3.org/1998/Math/MathML" href="javascript:alert(location)">click page
</math>

Upload the above contents as math.mml, open the URL directly in Firefox and click in the screen to open an alert.

Impact

It will allow attacks against Firefox users.

The original report as published on HackerOne, by ooooooo_q. 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 binary-format allowlist in Active Storage omitted application/mathml+xml, so Marcel fell back to the .mml extension and the file was served inline as active content.

Impact

Script could run in the site's origin for Firefox users who click the uploaded file; the report only claims this for Firefox.

What the attacker needed

Ability to upload a file; victim uses Firefox; victim clicks the file link

The fix

The binary-format list should include application/mathml+xml so such uploads are not treated as binary.

How it was found

  1. Create a MathML file containing a javascript link and name it with the .mml extension.
  2. Upload it to Active Storage.
  3. Open the file's URL directly in Firefox.
  4. Click on the page to trigger the script.

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 upload a file, the server decides what type it is so it knows whether to show it in the browser or offer it as a download. Here a MathML file was treated as something the browser should display, and MathML can contain clickable links that run JavaScript. So a malicious upload could run code in the victim's browser when they clicked it.

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 ooooooo_q

View all

53 more disclosed reports, best first.

More from Ruby on Rails

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.