serve cross-site scripting in directory listing

Severity: info · Published 2020-09-11

serve is a popular Node.js HTTP server package used to host static files and directories. Versions before 10.0.2 fail to properly escape user-controlled input in directory listing pages, allowing attackers to inject malicious JavaScript code that executes in visitors' browsers. This can lead to credential theft, session hijacking, or defacement of the served content.

Technologies: serve (npm). Vendors: npm.

Quick answers

Is This vulnerability exploited in the wild?
No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.
How severe is This vulnerability?
Informational severity, published 11 September 2020.
Which products and versions are affected?
serve (npm) SEMVER:introduced=0,fixed=10.0.2.
Is there a fix for This vulnerability?
Yes. serve (npm): upgrade to 10.0.2 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is This vulnerability attacked?
It is attacked over the network.
Am I affected?
Check whether you run serve (npm) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • serve (npm): upgrade to 10.0.2 or later
    npm install serve@10.0.2

Technical details

The vulnerability is a reflected Cross-Site Scripting (XSS) flaw (CWE-79) in the directory listing template (directory.jst) that fails to encode output when rendering user-supplied input such as directory names. An attacker can craft a malicious directory name containing JavaScript payload; when a victim visits the directory listing page, the unescaped payload executes in their browser context with the same privileges as the serve application. The fix (commit 65b4d41) properly escapes template variables using the `{{ = ... }}` template syntax. Exploitation requires only network access to the serve instance and no authentication.

Affected products

  • Vercel serve < 10.0.2

Timeline

  • 2020-09-11: disclosed
  • 2020-09-11: patched: Fixed in version 10.0.2

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.