[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.
- 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
flsabamodule: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")>"'
- a file with name

- in the same directory (in my case is
~/PoC), startflsaba:
~/PoC » flsaba
flsaba v1.1.0 server listening on port 3000
Directory: /home/ubuntu/PoC

- visit http://localhost:3000/
- the alerts will popup


Patch
The vulnerability arises in the following lines of code:
- https://github.com/petoem/flsaba/blob/master/server.js#L58
- https://github.com/petoem/flsaba/blob/master/server.js#L64
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.
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
- Install the flsaba module globally.
- Create a file with a name containing HTML and script.
- Create a directory with a name containing HTML and script.
- Start flsaba in the directory being served.
- 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.