VYPR
High severityNVD Advisory· Published Jan 25, 2023· Updated Apr 1, 2025

CVE-2022-21192

CVE-2022-21192

Description

All versions of the package serve-lite are vulnerable to Directory Traversal due to missing input sanitization or other checks and protections employed to the req.url passed as-is to path.join().

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
serve-litenpm
<= 1.1.0

Affected products

2

Patches

Vulnerability mechanics

Root cause

"Missing input sanitization on `req.url` before passing it to `path.join()` allows directory traversal."

Attack vector

An attacker sends an HTTP GET request to the server with a URL containing `../` sequences, such as `curl --path-as-is "http://localhost:3000/../package.json"` [ref_id=1][ref_id=2]. Because the `req.url` is passed as-is to `path.join()` without sanitization, the path traversal sequences resolve to files outside the intended static root directory [CWE-22][ref_id=1]. The server then reads and returns the contents of the traversed file to the attacker [ref_id=2].

Affected code

The vulnerability resides in `server.js` at lines 111–114 and 140–145 [ref_id=2]. The `decodeURIComponent(req.url)` is stripped of its leading `/` and passed directly to `path.join(root, filename)` without any sanitization, and the resulting path is then used in `fs.createReadStream(file).pipe(res)` to serve the file [ref_id=2].

What the fix does

The advisory states that upgrading serve-lite to version 1.1.1 or higher fixes the vulnerability [ref_id=1]. No patch diff is provided in the bundle, but the remediation guidance is to upgrade the package. The fix presumably adds input sanitization or validation to the `req.url` before it is used in `path.join()`, preventing directory traversal sequences from escaping the static root directory.

Preconditions

  • configThe serve-lite server must be running and serving static files from a root directory.
  • networkThe attacker must have network access to the server's HTTP endpoint.
  • authNo authentication is required; the vulnerability is exploitable by any unauthenticated HTTP client.

Reproduction

1. Install the vulnerable version: `npm install --save serve-lite@1.1.0` [ref_id=1][ref_id=2]. 2. Ensure a `public/` directory with files exists alongside `server.js` and `package.json` [ref_id=1][ref_id=2]. 3. Start the server: `node server.js 3000 public/` [ref_id=1][ref_id=2]. 4. Send a path traversal request: `curl --path-as-is "http://localhost:3000/../package.json"` and observe the contents of `package.json` returned in the response [ref_id=1][ref_id=2].

Generated on May 27, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

4

News mentions

0

No linked articles in our index yet.