Skip to content
DoS Disclosed report Intermediate

Application level denial of service due to shutting down the server

A URL path that becomes empty after the module's path-traversal sanitising loop causes the server to resolve the request to a directory instead of a file. Reading that directory yields undefined data, and writing it to the response throws an error that shuts the server down.

3la2kb Follow

Originally disclosed on HackerOne

  • Triaged in 39 hours
  • Fixed in 2 months
  • Disclosed after 3 months

Module

module name: http-live-simulator version: 1.0.7 npm page: https://www.npmjs.com/package/http-live-simulator

Description

I've found a way to crash the server due to the way it parses URL

Steps To Reproduce:

1- Install the module : npm install -g http-live-simulator 2- Run the server : http-live 3- Attempt to crash the server by this command curl --path-as-is http://localhost:8080/../?a

Explanation :

the reason for this issue is the fix for my previous report which is :

JavaScript
	var pathname = url.parse(req.url, true).pathname;
	while(pathname.indexOf("/../") != -1) {
		pathname = pathname.replace("/../",""); //fix for path traversal bug
	}

so now if we pass http://localhost:8080/../?a as the url the pathname becomes empty which will cause skipping this condition :

JavaScript
		if (pathname == "/") {
			for(var i=0;i<defaults.length;i++) {
				if (fs.existsSync(process.cwd() + '/' + defaults[i])) {
					pathname = '/' + defaults[i];
					break;
				}
			}
			if (pathname == '/') {
				return404(res, pathname);
				console.log(pathname);
				return;
			}
		}

with this in mind now we can proceed to the buggy snippet :

JavaScript
		abspath = process.cwd() + pathname;
		console.log('REQUEST: ', req.method, pathname);

		if (fs.existsSync(abspath)) {
			console.log("in condition");
			fs.readFile(abspath, function(err, data) {
				console.log("in condition1");
				var ext = pathname.slice(pathname.indexOf("."));
				var mtype = getMimeType(ext);
				res.writeHead(200, {'Content-Type': mtype});
				console.log(abspath, data);
				res.write(data);
				res.end();
			});
		}

here abspath becomes <project_dir> which cannot be read by readFile because it's a directory not a file causing the value of data to be undefined which will cause an error when trying to res.write(data); as res.write() function expects its parameter to be a string or buffer but it's undefined in this case.

Fix :

append a / to pathname if it becomes empty after sanitizing

Impact

Denial of service due to shutting down the server

The original report as published on HackerOne, by 3la2kb. 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 sanitising loop can reduce the pathname to an empty string, which skips the default-file and 404 handling and lets a directory path reach the file read and response write.

Impact

The server process shuts down, causing a denial of service for anyone relying on it.

What the attacker needed

Network access to the running server

The fix

The pathname should have a slash appended when it becomes empty after sanitising.

How it was found

  1. Install the module globally with npm.
  2. Start the server with the http-live command.
  3. Send a request whose path is crafted so the sanitised pathname becomes empty.

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 package cleans up incoming URL paths by stripping out certain sequences. A crafted path leaves the cleaned path completely empty, so the server tries to read a folder as if it were a file. That fails in a way that throws an error and stops the whole server, so nobody can use it until it is restarted.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by 3la2kb

View all

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

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.