CVE-2020-7686: Directory Traversal in rollup-plugin-server
Summary
CVE-2020-7686: Directory traversal in rollup-plugin-server. Affects rollup-plugin-server versions < 0.7.0. No fix is published. 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 rollup-plugin-server is an npm package that provides a development server for Rollup.js, a module bundler for JavaScript. It allows developers to serve their Rollup-built projects locally during development. The vulnerability affects all versions of the rollup-plugin-dev-server package. This package is responsible for serving files from the content base directory to the development server. However, it lacks proper path sanitization in the readFile operation within the readFileFromContentBase function.
Vulnerability Detail
The vulnerability allows an attacker to perform directory traversal attacks by manipulating the path parameter of the readFile operation. By including '../' sequences in the path, an attacker can access files outside of the intended directory and potentially read sensitive information or execute arbitrary code. This vulnerability has a CVSS score of 7.5, indicating a high severity level. Exploiting this vulnerability can lead to unauthorized access, data leakage, and potential remote code execution.
How To Fix
No fixed version is published for this vulnerability.
Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →
Workaround
As a temporary workaround, developers can manually validate and sanitize the path parameter before passing it to the readFile operation. Here's an example of how to sanitize the path using the path module in Node.js:
const path = require('path');
function sanitizePath(filePath) {
const basePath = '/path/to/content/base'; // Replace with the actual content base directory
const resolvedPath = path.resolve(basePath, filePath);
if (!resolvedPath.startsWith(basePath)) {
throw new Error('Invalid file path');
}
return resolvedPath;
}
Conclusion
The rollup-plugin-dev-server package is vulnerable to a directory traversal attack due to the lack of path sanitization in the readFile operation. This can lead to unauthorized access, data leakage, and potential remote code execution. It is crucial for the package maintainers to address this vulnerability by implementing proper path sanitization and access controls. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for rollup-plugin-server →
FAQ
rollup-plugin-server is an npm package that provides a development server for Rollup.js, allowing developers to serve their Rollup-built projects locally during development.
Directory traversal is a vulnerability that allows an attacker to access files and directories outside of the intended scope by manipulating file paths.
Exploiting this vulnerability can lead to unauthorized access, data leakage, and potential remote code execution.
To fix this vulnerability, the package maintainers should implement proper path sanitization in the readFile operation and restrict access to sensitive files and directories.
As a temporary workaround, developers can manually validate and sanitize the path parameter before passing it to the readFile operation.
References
Related vulnerabilities
Recent vulnerabilities recorded for rollup-plugin-server.