@fastify/middieの脆弱性により認証などのミドルウェアを回避される可能性
Summary
@fastify/middieの8.3.0から9.3.6までには、配列で指定したマウントパスの末尾のスラッシュやルートパスが正しく処理されず、パス単位のミドルウェアが一部のサブルートで適用されない脆弱性があります。認証や認可が働かないまま保護されたルートに到達されるおそれがあり、CVSSは7.4です。9.3.7で修正されているため、9.3.7以降へのアップデートをおすすめします。
AI summary
Produced by SecPulse using an external AI model; it may contain mistakes. Check the original description and references below before acting on it.
@fastify/middieの8.3.0から9.3.6までには、配列で指定したマウントパスの末尾のスラッシュやルートパスが正しく処理されず、パス単位のミドルウェアが一部のサブルートで適用されない脆弱性があります。認証や認可が働かないまま保護されたルートに到達されるおそれがあり、CVSSは7.4です。9.3.7で修正されているため、9.3.7以降へのアップデートをおすすめします。
Affected packages
| Package | Affected → Fixed | |
|---|---|---|
| @fastify/middie@fastify/middie |
≥ 8.3.0, < 9.3.7→ 9.3.7 |
9.3.7 |
Original description The description as published by the source.
@fastify/middie is the middleware engine that adds Express and Connect style middleware support to Fastify. In versions 8.3.0 through 9.3.6, the internal helper that normalizes a path-scoped middleware's mount path only handles string inputs, but the use method also accepts an array of mount paths and passes it through unchanged, so the normalization silently does nothing. As a result, a trailing slash on an array element survives into the generated route-matching regular expression, and an element that is exactly the root path, meaning a catch-all mount, is dropped entirely. Requests to subroutes of the affected mount paths then skip the path-scoped middleware, such as authentication, authorization, or rate limiting, while Fastify's router still dispatches them to the handler, allowing an unauthenticated client to reach protected routes. Applications are affected when they mount middleware on an array of paths in which an element ends with a slash, including one introduced by a plugin prefix that ends with a slash, or is exactly the root path. The issue is fixed in @fastify/middie 9.3.7, and users should upgrade to 9.3.7 or later. As a workaround, enforce authorization in a Fastify hook such as preHandler that runs after routing, and avoid array mount paths with a trailing slash element for security relevant middleware.
Source: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory
References
- advisory github.com
- advisory cna.openjsf.org
- advisory github.com
- advisory nvd.nist.gov