/

CVE-2026-76844

Severity:

HIGH RISK

(7.4)

Path Traversal (CWE-22) in webpack-dev-middleware

CVE-2026-76844

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Unauthorized File Read

Severity:

HIGH RISK

(7.4)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A path traversal vulnerability in webpack-dev-middleware can cause requests to resolve outside the configured output directory when a publicPath without a trailing slash is used.

If the middleware can read from a physical filesystem, an attacker may retrieve files located one directory above the intended output path.

Affected context

The issue occurs in webpack-dev-middleware deployments where:

  • The configured publicPath does not end with a trailing slash
  • Request paths are converted into filesystem paths by getFilenameFromUrl
  • The middleware uses a physical filesystem through writeToDisk or a custom outputFileSystem

Deployments using the default publicPath value of "auto", which resolves to "/", are not affected by this specific path construction condition. The default in-memory filesystem may also limit exposure because it generally contains only generated build output.

Exploit preconditions

  • Attack surface: HTTP request handling by webpack-dev-middleware
  • Required access: Ability to send requests to the development or asset-serving endpoint
  • Configuration requirement: A publicPath without a trailing slash must be configured
  • Filesystem requirement: The middleware must be backed by a physical filesystem, such as through writeToDisk or a custom outputFileSystem
  • Trigger point: Filename resolution in getFilenameFromUrl
  • Why exploitation is possible: A prefix check and fixed-length slice can disagree about path boundaries, allowing a crafted pathname to produce a parent-directory component after slicing

Why this happens

The underlying bug is an inconsistent path-boundary model between validation and path construction. The traversal guard evaluates normalized path segments, while containment relies on a string prefix comparison and the later slice assumes that the publicPath ends at the same logical boundary.

When the publicPath has no trailing slash, a dot-dot sequence embedded in the adjacent pathname segment can evade the segment-based guard. The fixed offset then exposes a parent-directory component to path.join, which can resolve outside the intended output directory. This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').

Potential impact

  • An attacker may read sensitive files located one directory above the configured output path
  • Source files, environment-related files, or deployment metadata could be exposed
  • Development credentials or service configuration may be disclosed
  • The affected development or asset-serving process could lose confidentiality
  • Downstream compromise could become possible if exposed files contain secrets

General mitigation guidance

Mitigation generally focuses on making URL-to-filesystem mapping boundary-aware and reducing filesystem exposure.

Common defensive patterns include:

  • Resolve candidate paths and verify they remain within the intended directory using canonical path containment checks
  • Treat publicPath and pathname boundaries as structured path components rather than raw string prefixes
  • Reject traversal indicators after consistent URL decoding and normalization
  • Prefer an isolated, read-only, in-memory filesystem for development output when disk access is unnecessary
  • Restrict writeToDisk and custom filesystem access to narrowly scoped output directories
  • Run development middleware with least-privilege filesystem permissions and without access to sensitive parent directories
  • Avoid exposing development middleware directly to untrusted networks

How teams detect issues like this

Detection can combine code inspection, configuration review, and runtime monitoring:

  • Use static analysis rules to identify path.join or equivalent calls fed by request-derived strings
  • Review code for startsWith-based containment checks, fixed-offset pathname slicing, and validation performed before a separate path transformation
  • Flag publicPath configurations that lack explicit trailing-slash or boundary handling
  • Inventory deployments using writeToDisk or custom outputFileSystem implementations
  • Test URL-to-file mapping with boundary-adjacent names, encoded separators, and parent-directory representations in isolated environments
  • Enforce policies that prevent development asset servers from reading outside approved output roots

Automated code review and security testing tools can help identify inconsistent normalization and containment logic.

Sources

SourceLink
github.comgithub.com/advisories/GHSA-wr3j-pwj9-hqq6
github.comgithub.com/webpack/webpack-dev-middleware
github.comgithub.com/webpack/webpack-dev-middleware/blob/v8.1.1/src/middleware.js
vulncheck.comvulncheck.com/advisories/webpack-dev-middleware-path-traversal-via-offset-slice-on-a-non-slash-terminated-publicpath

Frequently asked

questions

It can be exploitable through HTTP requests when the affected middleware is reachable by an attacker and the required publicPath and filesystem conditions are present. It is primarily relevant to exposed development or asset-serving environments.

The attacker generally needs network access to the middleware endpoint and the ability to submit crafted request paths. They do not necessarily need filesystem credentials, but the middleware process must already have access to the physical files.

Use canonical, boundary-aware containment checks after consistent normalization and ensure that the resolved path remains inside the permitted output directory. Limiting the middleware to an isolated filesystem further reduces exposure.

Treat URL paths as untrusted input, avoid raw prefix checks and fixed offset assumptions, test publicPath boundary cases, restrict development servers to trusted networks, and apply least-privilege filesystem permissions.

Find out what's already
exploitable in your codebase.