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

[html-pages] Stored XSS in the filename when directories listing

The html-pages development server did not sanitise directory names before inserting them into the HTML of its directory listing page. An attacker who could create a directory with a crafted name could cause JavaScript to run in the browser of anyone who viewed that listing.

tungpun Follow

Originally disclosed on HackerOne

High 7.3 View original
  • Triaged in 9 days
  • Fixed in 2 months
  • Disclosed after 3 months

I would like to report a Store XSS vulnerability in html-pages It allows executing malicious javascript code in the user's browser.

Module

module name: html-pages version: 2.1.1 npm page: https://www.npmjs.com/package/html-pages

Module Description

Simple development http server for file serving and directory listing made by a Designer. Use it for hacking your HTML/JavaScript/CSS files, but not for deploying your final site.

Vulnerability

Steps To Reproduce:

  • Install the module:

$ npm install html-pages

  • On the working directory, create a new child directory with name: "><svg onload=alert(5);>

  • Start the server:

$ ./node_modules/html-pages/bin/index.js -p 6060

  • Go to http://127.0.0.1:6060/, then click on the directory "><svg onload=alert(5);>

or open http://127.0.0.1:6060/%22%3E%3Csvg%20onload=alert(5);%3E/ directly, the XSS popup will fire:

hp.png
hp.png From the original on HackerOne

Vulnerability Description

This issue happens because of the lack of path sanitization.

HTML output:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>Files within nodejs-example/"><svg onload=alert(5);></title>
    <meta name="description" content="">
    <link rel="stylesheet" href="/@html-pages-internal-files-hoihj6ey0qu/css/style.css">
    <link rel="stylesheet" href="/@html-pages-internal-files-hoihj6ey0qu/css/component.css">
    <link rel="stylesheet" href="/@html-pages-internal-files-hoihj6ey0qu/css/loader.css">
    <link rel="icon" type="image/svg+xml" href="/@html-pages-internal-files-hoihj6ey0qu/images/logo.svg">
  </head>

  <body>
    <header>
      <div class="wrapper">
        <nav>
          <ol class="breadcrumb custom-separator">
              <li class="">
                <a class="background-effect" href="/">nodejs-example</a>
              </li>
              <li class="current">
                <span>"><svg onload=alert(5);></span>
              </li>
          </ol>
        </nav>

[...]

Supporting Material/References:

  • macOS High Sierra 10.13.3
  • node v8.10.0
  • npm 5.6.0
  • Firefox 59.0.2 (64-bit)

Wrap up

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

Impact

It allows executing malicious javascript code in the user's browser

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

Impact

An attacker could run malicious JavaScript in the browser of a user who viewed the crafted directory listing.

What the attacker needed

Ability to create a directory with a crafted name; victim views the directory listing

How it was found

  1. Install the html-pages module.
  2. Create a child directory whose name contains HTML markup.
  3. Start the html-pages server.
  4. Open the server root and click the crafted directory, or open its URL directly.
  5. The script in the directory name runs 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.

A small web server that lists files in a folder put the folder's name into the page without cleaning it first. If a folder name contains HTML code, the browser treats that code as part of the page and runs it. This lets someone run their own script in another person's browser when that person opens the folder listing.

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 tungpun

View all

11 more disclosed reports, best first.

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.