Advisory

GHSA-6hw5-45gm-fj88

Details, part 2 of 2. The advisory

Details

The bypass works against all Express middleware that uses prefix path matching, including popular packages like express-basic-auth, custom authentication middleware, and rate limiting middleware.

The ignoreDuplicateSlashes and useSemicolonDelimiter options are documented as convenience features, not marked as security-sensitive, so developers would not expect them to impact middleware security.

Affected Versions

  • @fastify/express v4.0.4 (latest) with Fastify 5.x
  • Requires ignoreDuplicateSlashes: true or useSemicolonDelimiter: true in Fastify configuration (via top-level option or routerOptions)

Variant Testing

Duplicate slashes:

| Request | Express Middleware | Handler Runs | Result |
|---------|-------------------|--------------|--------|
| GET /admin/dashboard | Invoked (blocks) | No | 403 Forbidden |
| GET //admin/dashboard | Skipped | Yes | 200 OK — BYPASS |
| GET ///admin/dashboard | Skipped | Yes | 200 OK — BYPASS |
| GET /.//admin/dashboard | Skipped | Yes | 200 OK — BYPASS |
| GET //admin//dashboard | Skipped | Yes | 200 OK — BYPASS |
| GET /admin//dashboard | Invoked (blocks) | No | 403 Forbidden |

Semicolons:

| URL | Express MW Fires | Route Matches | Result |
|---|---|---|---|
| /admin | Yes | Yes (200/403) | Normal |
| /admin; | No | Yes (200) | BYPASS |
| /admin;bypass | No | Yes (200) | BYPASS |
| /admin;x=1 | No | Yes (200) | BYPASS |
| /admin;/dashboard | No | Yes (200, routes to /admin) | BYPASS |
| /admin/dashboard;x | Yes | Yes (routes to /admin/dashboard) | Normal (prefix /admin/ still matches) |

The semicolon bypass is effective when the semicolon appears immediately after the middleware prefix boundary. For sub-paths where the prefix is already matched (e.g., /admin/dashboard;x), Express's prefix regex succeeds because the /admin/ part matches before the semicolon appears.

Suggested Fix

@fastify/express should normalize URLs before passing them to Express middleware, respecting the router normalization options that are enabled. Specifically:

  • When ignoreDuplicateSlashes is enabled, apply FindMyWay.removeDuplicateSlashes() to req.raw.url before middleware execution
  • When useSemicolonDelimiter is enabled, strip semicolon-delimited parameters from the URL before passing to Express

This would match the normalization behavior that @fastify/middie already implements via sanitizeUrlPath() and normalizePathForMatching().

Sources & licences