CVE-2018-3787: Path Traversal Vulnerability in simplehttpserver
Summary
CVE-2018-3787: simplehttpserver allows directory traversal and file listing. Affects simplehttpserver versions < 0.2.1. Fixed in 0.2.1. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
simplehttpserver is an npm package that provides a basic HTTP server for serving static files. It is commonly used for local development and testing purposes. The package allows users to easily start a server and serve files from a specified directory. However, versions prior to 0.2.1 are vulnerable to a path traversal attack, which allows an attacker to list any file on the server.
Vulnerability Detail
The path traversal vulnerability in simplehttpserver allows an attacker to bypass the intended file serving restrictions and access files outside of the specified directory. By manipulating the file path in the HTTP request, an attacker can traverse directories and retrieve sensitive files that should not be accessible. This can lead to unauthorized disclosure of sensitive information or potential remote code execution if the server is running with elevated privileges.
How To Fix
Latest published version: 0.3.0 as of 22 Oct 2026
npm install simplehttpserver@0.3.0
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
0.2.1
This is the first release that contains the fix.
npm install simplehttpserver@0.2.1
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If upgrading to the latest version is not possible, a temporary workaround is to manually validate and sanitize the file paths in the server code. This can be done by checking if the requested file path is within the allowed directory and rejecting any requests that attempt to access files outside of it. Here is an example of how to implement this workaround in Node.js:
const http = require('http');
const path = require('path');
const server = http.createServer((req, res) => {
const filePath = path.join(__dirname, 'public', req.url);
const allowedDirectory = path.join(__dirname, 'public');
if (!filePath.startsWith(allowedDirectory)) {
res.statusCode = 403;
res.end('Forbidden');
return;
}
// Rest of the server logic
});
server.listen(3000);
Conclusion
The path traversal vulnerability in simplehttpserver can be mitigated by upgrading to version 0.2.1 or later. If upgrading is not feasible, implementing the provided workaround can help protect against this vulnerability. For further assistance or support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for simplehttpserver →
FAQ
simplehttpserver is an npm package that provides a basic HTTP server for serving static files. It is commonly used for local development and testing purposes.
A path traversal vulnerability allows an attacker to access files outside of the intended directory by manipulating the file path in the HTTP request.
The path traversal vulnerability in simplehttpserver can lead to unauthorized disclosure of sensitive information or potential remote code execution if the server is running with elevated privileges.
To fix this vulnerability, it is recommended to upgrade to version 0.2.1 or later of the simplehttpserver package. Alternatively, you can manually validate and sanitize file paths in the server code to restrict access to the intended directory.
Yes, if upgrading to the latest version is not possible, you can implement a workaround by manually validating and sanitizing file paths in the server code. See the 'workaround' section for an example.
Related vulnerabilities
Recent vulnerabilities recorded for simplehttpserver.