# CVE-2026-112712: @fastify/middie vulnerable to path-scoped middleware bypass via scope prefix mismatch

Source: https://aplosec.si/cve/CVE-2026-112712/

[AploSec](https://aplosec.si/) / [Disclosures](https://aplosec.si/disclosures/) / CVE-2026-112712

Critical 9.1 · Reported · Fixed in 9.3.6 · CWE-436 · Multiple credited contributors · npm

# @fastify/middie vulnerable to path-scoped middleware bypass via scope prefix mismatch

CVE-2026-112712 · published 2026-10-20

In plain words: this type of bug lets two parts of a system read the same input differently, so a check can be slipped past (parsing mismatch). A fixed release is listed.

## Summary

CVE-2026-112712 affects @fastify/middie (npm) 9.0.0 before 9.3.6: Auth middleware bypass via scope prefix (CWE-436). Fixed in 9.3.6. CVSS 3.1 base score 9.1 (Critical), assigned by OpenJS Foundation. Published 2026-10-20 by openjs. Credit: zachariah-mithani, mcollina, UlisesGascon.

@fastify/middie is the Express-style middleware engine for Fastify. In versions from 9.0.0 through 9.3.5, the use() function joined a path-scoped middleware's mount path to the plugin scope prefix in a way that could diverge from the path Fastify's router serves, most often when the scope prefix ended in a slash, and also for array mount paths and for mount paths written without a leading slash. When the two paths disagreed, the middleware was silently skipped while the route handler still ran, so path-scoped middleware such as authentication, authorization, or rate limiting could be bypassed by a single unauthenticated request. The issue is fixed in @fastify/middie 9.3.6, and users should upgrade to 9.3.6 or later. As a workaround, enforce authorization in a Fastify hook such as preHandler that runs after the router has resolved the request.

## Write-up

### What middie does

@fastify/middie lets a Fastify app use Express-style middleware. A common pattern mounts an auth check on part of the app:

```
app.register(async (scope) => {
  scope.use('/secret', requireLogin)
  scope.get('/secret/data', handler)
}, { prefix: '/api/' })
```

The intent is clear: anything under /api/secret needs a login.

### The bug

middie builds the middleware's mount path by joining the plugin prefix and the use() path. With a prefix that ends in /, it stored the mount as /api//secret, with a double slash. Fastify's router does not see it that way: it serves the route at /api/secret/data.

The router and the middleware matcher disagreed about the path. A request to GET /api/secret/data matched the route, so the handler ran. It never matched /api//secret, so requireLogin never ran. Nothing failed loudly: the middleware was skipped and the protected data came back.

The same mismatch appeared with array mount paths (use(['/secret'], auth)) and with mount paths written without a leading slash (use('secret', auth)). No credentials and no unusual request are needed. A normal request to the protected route is enough.

### Why it is easy to miss

Each part works on its own. The route works and the middleware works when tested directly. The failure only shows up when the two compute the same path differently, and a trailing slash in a prefix looks like a style choice, not a security setting.

### Fix and advice

Upgrade to @fastify/middie 9.3.6 or later. If you cannot upgrade right away, enforce authorization in a Fastify hook such as preHandler. Hooks run after the router has resolved the request, so they see the same path the handler does.

The general lesson: when a security check and the code it protects each parse the request path, they must use the same parser. Two parsers that mostly agree is how bypasses happen.

### Timeline

- 2026-10: reported privately to the Fastify team through GitHub security advisories

- 2026-10-20: fix released in 9.3.6, advisory GHSA-5p92-8765-9fv8 published, CVE-2026-112712 assigned

Thanks to the Fastify maintainers for a fast fix.

## Evidence

Reported to the maintainer. The public advisory and references below describe the evidence and preconditions; reporting status alone does not establish independent reproduction.

## Remediation

Upgrade @fastify/middie to 9.3.6 or later. Releases in the affected range (9.0.0 before 9.3.6) are vulnerable. See the linked advisory for details on affected release lines.

## Timeline

- 2026-10-20 CVE published

- 2026-11-01 Public record last updated

## References

- [Referencehttps://github.com/fastify/middie/security/advisories/GHSA-5p92-8765-9fv8](https://github.com/fastify/middie/security/advisories/GHSA-5p92-8765-9fv8)

- [Referencehttps://cna.openjsf.org/security-advisories.html](https://cna.openjsf.org/security-advisories.html)

- [CVE recordhttps://www.cve.org/CVERecord?id=CVE-2026-112712](https://www.cve.org/CVERecord?id=CVE-2026-112712)

- [NVD recordhttps://nvd.nist.gov/vuln/detail/CVE-2026-112712](https://nvd.nist.gov/vuln/detail/CVE-2026-112712)

**Severity:** Critical 9.1 CVSS 3.1, scored by OpenJS Foundation in the [CVE record](https://www.cve.org/CVERecord?id=CVE-2026-112712)

**Package:** @fastify/middie

**Ecosystem:** npm

**Affected:** 9.0.0 before 9.3.6

**Fixed:** 9.3.6

**Weakness:** CWE-436

**CNA:** openjs

**Credit:** zachariah-mithani reporter · mcollina remediation developer · UlisesGascon remediation developer
