# serve cross-site scripting in directory listing

Source: https://junglewise.ai/threats/serve-cross-site-scripting-in-directory-listing-bd56c0df  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2020-09-11. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

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)](https://junglewise.ai/threats/technologies/serve). Vendors: [npm](https://junglewise.ai/threats/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

  ```sh
  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

- [https://github.com/zeit/serve-handler/commit/65b4d4183a31a8076c78c40118acb0ca1b64f620](https://github.com/zeit/serve-handler/commit/65b4d4183a31a8076c78c40118acb0ca1b64f620)
- [https://hackerone.com/reports/358641](https://hackerone.com/reports/358641)

## Related threats

- [Vercel serve path traversal via URL encoding](https://junglewise.ai/threats/cve-2018-3718-vercel-serve-path-traversal-via-url-encoding)
- [serve Cross-Site Scripting in filename handling](https://junglewise.ai/threats/serve-cross-site-scripting-in-filename-handling-f9ba227e)
- [serve Path Traversal via explicitly ignored folders](https://junglewise.ai/threats/serve-path-traversal-via-explicitly-ignored-folders-70a1a073)
- [serve path validation bypass via URL encoding](https://junglewise.ai/threats/serve-path-validation-bypass-via-url-encoding-c91ec671)
- [serve directory traversal](https://junglewise.ai/threats/cve-2019-5417-serve-directory-traversal)
