CVE-2018-3734: Path Traversal in stattic
Summary
CVE-2018-3734: Path Traversal in stattic. Affects stattic versions < 0.3.0. Fixed in 0.3.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
The stattic package is an npm package used for serving static files in Node.js applications. It allows developers to easily serve static assets such as HTML, CSS, JavaScript, and images. However, versions of stattic before 0.3.0 are vulnerable to a path traversal attack, which can be exploited by a remote attacker to read arbitrary files from the server. This vulnerability poses a high risk to the confidentiality of sensitive information stored on the server.
Vulnerability Detail
The vulnerability in stattic arises from insufficient input validation, allowing an attacker to manipulate file paths and access files outside of the intended directory. By exploiting this vulnerability, an attacker can read any file on the server, regardless of its extension. This could lead to the unauthorized disclosure of sensitive information, such as configuration files or user data. The vulnerability has been assigned a CVSS score of 7.5, indicating a high severity level.
How To Fix
Minimum fixed version
0.3.0
This is the first release that contains the fix.
npm install stattic@0.3.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 is not immediately possible, a temporary workaround is to implement additional input validation and sanitization of user-supplied file paths. This can be done by checking that the requested file path is within the expected directory and does not contain any directory traversal characters. Here is an example of how to implement this workaround in Node.js:
const path = require('path');
function serveStaticFile(req, res) {
const requestedFile = req.params.file;
const basePath = '/path/to/static/files';
const resolvedPath = path.resolve(basePath, requestedFile);
if (!resolvedPath.startsWith(basePath)) {
// Invalid file path
res.status(400).send('Invalid file path');
return;
}
// Serve the file
// ...
}
Conclusion
In conclusion, the stattic package versions before 0.3.0 are vulnerable to a path traversal attack, which can be exploited to read arbitrary files from the server. To mitigate this vulnerability, it is crucial to update to version 0.3.0 or later. Implementing additional input validation and sanitization of file paths can serve as a temporary workaround until the update is applied. For further assistance and support in vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for stattic →
FAQ
This vulnerability allows an attacker to read arbitrary files from the server, potentially exposing sensitive information. It can lead to unauthorized access, data breaches, and other security incidents.
No, only versions before 0.3.0 are vulnerable to this path traversal attack. It is recommended to update to version 0.3.0 or later to mitigate the vulnerability.
While there are no known public exploits for this specific vulnerability in stattic, it is important to address it promptly to prevent potential attacks. Attackers often actively search for and exploit known vulnerabilities in popular packages.
Yes, this vulnerability has been assigned a CVSS score of 7.5, indicating a high severity level.
You can find more information about this vulnerability, including its technical details and affected versions, in the GitHub Security Advisory database: https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2018/07/GHSA-w4pv-w56c-mg4v/GHSA-w4pv-w56c-mg4v.json