Skip to content
XSS Disclosed report Beginner

[flsaba] Stored XSS in the file and directory name when directories listing

The flsaba module builds directory listing pages by inserting file and directory names into HTML anchor elements without sanitisation. An attacker who can create a file or directory with a crafted name can store a script that executes in the browser of anyone who views the listing.

d3lla Follow

Originally disclosed on HackerOne

  • Triaged in 42 hours
  • Fixed in 5 months
  • Disclosed after 5 months

I would like to report a Stored XSS in module "flsaba". It allows to inject malicious scripts in the file and directory name, store them on the server, then execute these scripts in the browser via the XSS vulnerability.

Module

module name: https://www.npmjs.com/package/flsaba version: 1.1.0 npm page: https://www.npmjs.com/package/flsaba

Module Description

simple http server with directory listing

Module Stats

[5] weekly downloads

Vulnerability

Vulnerability Description

This XSS vulnerability occurs due to the module represents file and directory name(s) in HTML when creating the listing directory page. The file and directory name(s) are used in the href attribute of an anchor element (as well as the value of the anchor itself) without any sanitization. In this way, any malicious script written in the file/directory name and stored on the server, would be executed in the client's browser.

Steps To Reproduce:

  • install the flsaba module:
    • npm install -g flsaba
  • in the directory which will be served via flsaba (in my case the directory is ~/PoC), create:
    • a file with name "><img src=x onerror=javascript:alert("xss")>":
      • touch '"><img src=x onerror=javascript:alert("xss")>"'
    • a directory with name "><img src=x onerror=javascript:alert("xss2")>" :
      • mkdir '"><img src=x onerror=javascript:alert("xss2")>"'
files.png
files.png From the original on HackerOne
  • in the same directory (in my case is ~/PoC), start flsaba:
Shell
~/PoC » flsaba                                                                     
flsaba v1.1.0 server listening on port 3000
Directory: /home/ubuntu/PoC
flsaba.png
flsaba.png From the original on HackerOne
PoC1.png
PoC1.png From the original on HackerOne
PoC2.png
PoC2.png

Patch

The vulnerability arises in the following lines of code:

Supporting Material/References:

  • OPERATING SYSTEM VERSION: Ubuntu 18.04.4 LTS
  • NODEJS VERSION: v13.13.0
  • NPM VERSION: 6.14.4
  • BROWSERS VERSIONS: Firefox Browser 75.0 (64-bit)

Wrap up

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

Thanks for your time.

Best regards,

d3lla

Impact

Stored XSS. Any malicious script written in the file/directory name and stored on the server, would be executed in the client's browser, so this vulnerability allows executing malicious JavaScript code in the client's browser.

The original report as published on HackerOne, by d3lla. 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 module inserts file and directory names into HTML anchor elements without sanitisation or escaping.

Impact

Any malicious script written in a file or directory name and stored on the server would be executed in the client's browser.

What the attacker needed

Ability to create files or directories on the server; victim visits the directory listing page

The fix

The module should escape or sanitise file and directory names before inserting them into HTML.

How it was found

  1. Install the flsaba module globally.
  2. Create a file with a name containing HTML and script.
  3. Create a directory with a name containing HTML and script.
  4. Start flsaba in the directory being served.
  5. Visit the local server page and observe the script executing.

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 directory listing is a web page that shows the files in a folder. This tool puts the file names directly into the page's HTML without cleaning them first. If a file name contains HTML code, the browser treats it as part of the page and runs any script in it, so a malicious file name can run code in a visitor's browser.

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 d3lla

View all

16 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.