Skip to content
XSS Disclosed report Beginner CVE-2018-16474

[tianma-static] Security issue with XSS.

The tianma-static module serves uploaded files with a content type derived from the file extension, so an uploaded HTML file is returned as text/html and its scripts execute. It also reflects a manipulated pathname into the response without proper encoding, allowing HTML injection and reflected XSS.

wooeong22 Follow

Originally disclosed on HackerOne

  • Disclosed after 16 months

I would like to report XSS in tianma-static It allows XSS and HTML Injection

First of all, It is my first report and I am sorry that I am not good at English T.T thank you.

Module

module name: tianma-static version: 1.0.4 npm page: https://www.npmjs.com/package/tianma-static

Module Description

Provide a static file service.

Vulnerability

Vulnerability Description

  1. File content type

when I look a CVE-2018-16474(CVE-2018-16474, #403692), I think that's vulnerability need arbitrary file(name) upload.

If upload is possible, Attacker can upload html file. Also content type of the response header becomes text/html and it is possible to Stored XSS.

1._html_File_Stored_XSS.png
1._html_File_Stored_XSS.png From the original on HackerOne
  1. HTML Injection (It can lead to reflected XSS)

when a send %2f in path (example: http://127.0.0.1:8080/%2f), resolve function make a normal path on the filesystem. but req.pathname will print out a manipulated path.

so I can insert any html.

2._HTML_injection.png
2._HTML_injection.png From the original on HackerOne

Reflected XSS using HTML only is not easy bypass the modern browser. but if I can upload any file, Reflected XSS is possible Using load script.

3._Reflected_XSS.png
3._Reflected_XSS.png From the original on HackerOne

Steps To Reproduce:

  1. File content type
  • upload html file with XSS script.
  • xss fired
  1. HTML Injection (reflected XSS)
  • upload any file with XSS script.
  • access /%2f<script src='/[filename]'></script>
  • xss fired

Patch

  1. add content type header in response.
  2. change decodeURI to decodeURIComponent. or denied malicious path.

Wrap up

  • I contacted the maintainer to let them know: N
  • I opened an issue in the related repository: N

Impact

If file upload is possible, XSS can occur.

The original report as published on HackerOne, by wooeong22. 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 server sets the response content type from the uploaded file's extension and reflects the decoded request path into the response without encoding.

Impact

If file upload is possible, an attacker could achieve stored or reflected cross-site scripting, though reflected XSS using only HTML is noted as not easy to bypass in modern browsers.

What the attacker needed

Ability to upload files; victim visits a crafted URL

The fix

The report suggests adding a content type header and changing decodeURI to decodeURIComponent or denying malicious paths, but does not state that a fix was applied.

How it was found

  1. Upload an HTML file containing a script.
  2. Access the uploaded file so the browser executes the script.
  3. Upload any file containing a script.
  4. Request a path containing an encoded slash followed by a script tag that loads the uploaded file.
  5. The script executes in the browser.

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.

This is a small web server that serves static files. If someone can upload an HTML file, the server tells the browser to treat it as a web page, so any script inside runs. Also, when a strange path is requested, the server puts that path into the page without cleaning it, letting an attacker insert HTML.

What is XSS?

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

More from Node.js third-party modules

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.