Packages / serve / Security

HighVulnerabilityGHSA-wm7q-rxch-43mxPublished 1 Sep 2020

Byass due to validation before canonicalization in serve

Affected releases · serve

  • 6.x6.0.0 – 6.5.1Fixed in 6.5.2
  • 5.x and older0.0.1 – 5.2.4No fix, no longer updated

On 6.x, the newest line:

npm install serve@6.5.2
14.x
  1. Not affected

    14.0.0 – 14.2.6

    12 releases, latest

6.x
  1. Affected

    6.0.0 – 6.5.1

    25 releases

  2. Fixed

    6.5.2 – 6.5.8

    7 releases

5.x
  1. Affected

    5.0.0 – 5.2.4

    16 releases

4.x
  1. Affected

    4.0.0 – 4.0.2

    3 releases

3.x
  1. Affected

    3.0.0 – 3.4.1

    19 releases

2.x
  1. Affected

    2.0.0 – 2.4.4

    11 releases

1.x
  1. Affected

    1.0.0 – 1.4.0

    8 releases

0.x
  1. Affected

    0.0.1 – 0.0.5

    5 releases

155 stable releases of serve, oldest to newest, one row per major.

Is your project affected?

Paste your package.json, or type the range you declare for serve. It is read in your browser and sent nowhere.

What happens

Versions of serve before 6.5.2 are vulnerable to the bypass of the ignore functionality. The bypass is possible because validation happens before canonicalization of paths and filenames.

Example: Here we have a server that ignores the file test.txt.

const serve = require('serve')
const server = serve(__dirname, {
      port: 1337,
      ignore: ['test.txt']
})

Using the URL encoded form of a letter (%65 instead of e) attacker can bypass the ignore control accessing the file.

curl http://localhost:1337/t%65st.txt

Additionally this technique can be used to get directory listings of ignored directories.

Recommendation

Update to version 6.5.2 or later.