Skip to content
Heist/ feed
HighFix available

Path traversal in webpack-dev-middleware

Type: advisorySource: OSV1 source record

### Summary _The **webpack-dev-middleware** middleware does not validate the supplied URL address sufficiently before returning the local file. It is possible to access any file on the developer's machine._ ### Details The middleware can either work with the physical filesystem when reading the files or it can use a virtualized in-memory _memfs_ filesystem. If _writeToDisk_ configuration option is set to **true**, the physical filesystem is used: [https://github.com/webpack/webpack-dev-middleware/blob/7ed24e0b9f53ad1562343f9f517f0f0ad2a70377/src/utils/setupOutputFileSystem.js#L21](https://github.com/webpack/webpack-dev-middleware/blob/7ed24e0b9f53ad1562343f9f517f0f0ad2a70377/src/utils/setupOutputFileSystem.js#L21) The _**getFilenameFromUrl**_ method is used to parse URL and build the local file path. The public path prefix is stripped from the URL, and the **unsecaped** path suffix is appended to the _outputPath_: [https://github.com/webpack/webpack-dev-middleware/blob/7ed24e0b9f53ad1562343f9f517f0f0ad2a70377/src/utils/getFilenameFromUrl.js#L82](https://github.com/webpack/webpack-dev-middleware/blob/7ed24e0b9f53ad1562343f9f517f0f0ad2a70377/src/utils/getFilenameFromUrl.js#L82) As the URL is not unescaped and normalized automatically before calling the midlleware, it is possible to use _%2e_ and _%2f_ sequences to perform path traversal attack. ### PoC _A blank project can be created containing the following configuration file **webpack.config.js**:_ `module.exports = { devServ

Announced Group revision 1
Original source ↗

GHSA-wr3j-pwj9-hqq6

Primary source · Revision 1

Imported from structured advisory data. Source references identify upstream records or fields; verify affected versions and your deployed configuration.

Security context

Source reference: osv:GHSA-wr3j-pwj9-hqq6

webpack-dev-middleware

Source reference: /affected/0/package/name

Affected versions
Not stated in this record
Fixed versions
7.1.0

Source reference: /affected/0/ranges

Prerequisites
Not stated in this record

webpack-dev-middleware

Source reference: /affected/1/package/name

Affected versions
Not stated in this record
Fixed versions
6.1.2

Source reference: /affected/1/ranges

Prerequisites
Not stated in this record

webpack-dev-middleware

Source reference: /affected/2/package/name

Affected versions
Not stated in this record
Fixed versions
5.3.4

Source reference: /affected/2/ranges

Prerequisites
Not stated in this record

Structured affected-version data

Original package identities and version rules from this source.

[
  {
    "ranges": [
      {
        "type": "SEMVER",
        "events": [
          {
            "introduced": "7.0.0"
          },
          {
            "fixed": "7.1.0"
          }
        ]
      }
    ],
    "package": {
      "name": "webpack-dev-middleware",
      "purl": "pkg:npm/webpack-dev-middleware",
      "ecosystem": "npm"
    },
    "database_specific": {
      "source": "https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/03/GHSA-wr3j-pwj9-hqq6/GHSA-wr3j-pwj9-hqq6.json"
    }
  },
  {
    "ranges": [
      {
        "type": "SEMVER",
        "events": [
          {
            "introduced": "6.0.0"
          },
          {
            "fixed": "6.1.2"
          }
        ]
      }
    ],
    "package": {
      "name": "webpack-dev-middleware",
      "purl": "pkg:npm/webpack-dev-middleware",
      "ecosystem": "npm"
    },
    "database_specific": {
      "source": "https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/03/GHSA-wr3j-pwj9-hqq6/GHSA-wr3j-pwj9-hqq6.json"
    }
  },
  {
    "ranges": [
      {
        "type": "SEMVER",
        "events": [
          {
            "introduced": "0"
          },
          {
            "fixed": "5.3.4"
          }
        ]
      }
    ],
    "package": {
      "name": "webpack-dev-middleware",
      "purl": "pkg:npm/webpack-dev-middleware",
      "ecosystem": "npm"
    },
    "database_specific": {
      "source": "https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/03/GHSA-wr3j-pwj9-hqq6/GHSA-wr3j-pwj9-hqq6.json",
      "last_known_affected_version_range": "<= 5.3.3"
    }
  }
]
Related CVEs
CVE-2024-29180

Source reference: /aliases

Publisher severity

high

Source reference: /database_specific/severity

Event
#72820 · Revision 1
Added to Heist Feed
Publisher date
Read the original announcement