CVE-2020-7683: Directory Traversal in rollup-plugin-server
Summary
CVE-2020-7683: 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 server plugin for Rollup, a module bundler for JavaScript. It allows developers to serve their bundled files locally during development. The vulnerability affects all versions of the rollup-plugin-server package. The package does not perform 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 file path passed to the readFile function. By including '../' sequences in the file path, an attacker can access files outside of the intended directory and potentially read sensitive information. This can lead to unauthorized access, information disclosure, 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 sanitize the file path before passing it to the readFile function. They should ensure that the file path only includes the necessary characters and does not allow any directory traversal sequences. Here is an example of how to sanitize the file path in JavaScript:
function sanitizeFilePath(filePath) {
// Remove any '../' sequences
filePath = filePath.replace(/\.\./g, '');
// Add the base directory path
filePath = '/path/to/content/' + filePath;
return filePath;
}
Conclusion
The rollup-plugin-server package is vulnerable to a directory traversal attack due to the lack of path sanitization in the readFile operation. Developers should upgrade to a patched version of the package to mitigate the vulnerability. In the meantime, they can use a temporary workaround to sanitize the file path. For further assistance with 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 server plugin for Rollup, a JavaScript module bundler. It allows developers to serve their bundled files locally during development.
Directory traversal is a technique used by attackers to access files and directories outside of the intended scope. By manipulating file paths, they can navigate to parent directories or other parts of the file system.
The vulnerability can lead to unauthorized access to sensitive files, information disclosure, and potential remote code execution. An attacker could read sensitive data, modify files, or execute arbitrary code on the affected system.
To fix the vulnerability, you should upgrade to a version of rollup-plugin-server that includes a patch for the issue. Update your package.json file to use a non-vulnerable version and run the package manager's update command to install the patched version.
As a temporary workaround, you can manually sanitize the file path before passing it to the readFile function. Remove any '../' sequences and ensure the file path only includes the necessary characters.
References
Related vulnerabilities
Recent vulnerabilities recorded for rollup-plugin-server.