Executive brief
The statics-server package, a tool used to serve static files and display directory listings, is vulnerable to a security flaw that allows attackers to execute malicious scripts in a user's browser. By placing a file with a specially crafted name in a directory served by the tool, an attacker can trigger a cross-site scripting (XSS) attack when a user views the directory index. This could lead to unauthorized actions being performed on behalf of the user or the theft of sensitive session information.
Technical details
A cross-site scripting (XSS) vulnerability exists in statics-server versions 0.0.9 and earlier. The vulnerability is located in the directory indexing logic within `index.js`, where filenames are retrieved via `fs.readdirSync` and concatenated into HTML `<a>` tags without proper escaping or neutralization. An attacker can exploit this by creating a file with a name containing HTML tags, such as an `<iframe>` or `<script>`. When a victim navigates to the directory listing, the malicious payload is rendered and executed in the context of the victim's browser session. This is classified as CWE-79.
Affected products
- statics-server project statics-server <= 0.0.9
Timeline
- 2018-07-20: advisory: NVD published CVE-2018-3771
- 2022-05-13: disclosed: GitHub Advisory published