CVE-2018-3729: Path Traversal in localhost-now
Summary
CVE-2018-3729: Path Traversal in localhost-now. Affects localhost-now versions < 1.0.2. Fixed in 1.0.2. 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
The localhost-now package is an npm package used for local development and testing purposes. It provides a simple way to create a local server and serve static files. The package is widely used in web development projects. However, versions prior to 1.0.2 are vulnerable to a path traversal attack, which allows a remote attacker to read the content of arbitrary files on the server.
Vulnerability Detail
The vulnerability in localhost-now arises from insufficient input validation. An attacker can exploit this vulnerability by crafting a malicious request that includes directory traversal sequences (e.g., '../') in the file path. When the server processes this request, it does not properly sanitize the file path, allowing the attacker to access files outside the intended directory. This can lead to unauthorized disclosure of sensitive information, such as configuration files or user data. The impact of this vulnerability is rated as HIGH with a CVSS score of 7.5.
How To Fix
Minimum fixed version
1.0.2
This is the first release that contains the fix.
npm install localhost-now@1.0.2
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If updating the package is not immediately feasible, a temporary workaround can be implemented by manually validating and sanitizing user input for file paths. This can be done by ensuring that the requested file path only contains allowed characters and does not include any directory traversal sequences. Here is an example of how to implement this workaround in Node.js:
const path = require('path');
function sanitizeFilePath(filePath) {
const allowedChars = /^[a-zA-Z0-9_-]+$/;
const sanitizedPath = path.normalize(filePath);
if (!allowedChars.test(sanitizedPath)) {
throw new Error('Invalid file path');
}
return sanitizedPath;
}
Conclusion
The localhost-now package prior to version 1.0.2 is vulnerable to a path traversal attack, which allows an attacker to read arbitrary files on the server. To mitigate this vulnerability, it is crucial to update to version 1.0.2 or later of the package. If immediate update is not possible, implementing a temporary workaround by validating and sanitizing user input for file paths can provide some protection. For more information and assistance, please contact DevNack.com.
See every vulnerability recorded for localhost-now →
FAQ
The vulnerability allows an attacker to read the content of arbitrary files on the server, potentially leading to unauthorized disclosure of sensitive information.
You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. Simply provide your package-lock.json file, and Vulert will analyze it for any open-source vulnerabilities, including this one.
Yes, updating to version 1.0.2 or later of the localhost-now package fixes this vulnerability. It is recommended to update as soon as possible.
Yes, a temporary workaround is to manually validate and sanitize user input for file paths to prevent path traversal attacks. See the 'workaround' section for an example implementation.
For further support on vulnerability remediation, you can contact info@devnack.com. They can provide guidance and assistance in addressing this vulnerability.
Related vulnerabilities
Recent vulnerabilities recorded for localhost-now.