CVE-2017-16085: Directory Traversal in tinyserver2
Summary
CVE-2017-16085: Directory Traversal in tinyserver2. Affects tinyserver2 versions < 0.6.0. Fixed in 0.6.0. 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
tinyserver2 is an npm package that provides a lightweight server for serving static files. It is designed to be simple and easy to use. However, versions of tinyserver2 up to and including 0.5.2 are vulnerable to a directory traversal attack. This vulnerability allows an attacker to access files outside of the intended directory root, potentially leading to the disclosure of sensitive information.
Vulnerability Detail
The vulnerability in tinyserver2 arises from its handling of relative file paths. By manipulating the file path in a specific way, an attacker can bypass the intended directory restrictions and access files outside of the server's root directory. This can result in the exposure of private files on the vulnerable system. An example request that demonstrates this vulnerability is:
GET /../../../etc/passwd HTTP/1.1 host: foo
This request attempts to access the /etc/passwd file, which contains sensitive user information.
This vulnerability has a severity rating of HIGH and is classified as CWE-22 (Path Traversal).
How To Fix
Latest published version: 0.6.1 as of 23 Oct 2026
npm install tinyserver2@0.6.1
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.6.0
This is the first release that contains the fix.
npm install tinyserver2@0.6.0
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If updating to the latest version of tinyserver2 is not possible, a temporary workaround is to implement input validation and sanitization for file paths. This can help prevent directory traversal attacks by ensuring that only valid and safe file paths are accepted by the server. Here is an example of how to sanitize file paths in Node.js:
const path = require('path');
function sanitizeFilePath(filePath) {
const rootDir = '/path/to/root'; // Replace with the actual root directory
const resolvedPath = path.resolve(rootDir, filePath);
if (!resolvedPath.startsWith(rootDir)) {
throw new Error('Invalid file path');
}
return resolvedPath;
}
This code snippet uses the path.resolve() function to resolve the file path relative to the root directory. It then checks if the resolved path is still within the root directory to ensure that no directory traversal has occurred. If the path is deemed invalid, an error is thrown.
Conclusion
In conclusion, the directory traversal vulnerability in tinyserver2 can lead to the disclosure of sensitive files on the vulnerable system. It is crucial to update to version 0.6.0 or later to fix this vulnerability. If updating is not feasible, implementing input validation and sanitization for file paths can provide a temporary workaround. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for tinyserver2 →
FAQ
The impact of this vulnerability is the potential disclosure of sensitive files on the vulnerable system. An attacker can access files outside of the intended directory root, which may include private user data, configuration files, or other sensitive information.
You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. The playground allows you to analyze your package-lock.json file and provides real-time alerts for open-source vulnerabilities, including this one.
Yes, updating to version 0.6.0 or later of tinyserver2 will fix this vulnerability. It is recommended to always use the latest version of the package to ensure the security of your application.
If updating to the latest version is not possible, you can implement input validation and sanitization for file paths to mitigate the risk. The provided code snippet demonstrates how to sanitize file paths in Node.js.
This vulnerability has a severity rating of HIGH.