@NESTJS/PLATFORM-FASTIFY · GHSA-9c5c-9qcx-q35q · Package
FIX → 12.0.2 and 11.2.4
Sending a request line with an absolute-form target (such as GET http://host/path) makes the Fastify adapter skip path-scoped Nest middleware, though the route handler still runs. Applications that enforce authentication or authorization in that middleware can have those checks bypassed.
first public Sep 15, 2026 · 1 source
Could this affect your app?
Free first check from your website. Connect your repo for the full answer.
Applications built on NestJS with the Fastify adapter that bind middleware to specific paths for authentication or authorization, and that accept raw HTTP requests from clients. Exposure is reduced when a reverse proxy rewrites request targets to origin-form, which most do. Apps not using the Fastify adapter, or not binding path-scoped middleware, can skip it.
Not affected if express-adapter, no-path-middleware, reverse-proxy-origin-form
Who cares fastify, nestjs, node, self-hosted
@nestjs/platform-fastify with npm ls @nestjs/platform-fastify; versions >= 12.0.0 below 12.0.2 and versions below 11.2.4 are affected.consumer.apply(...).forRoutes(...) or .exclude(...) in NestModule methods that guard routes with auth.| Field | Value |
|---|---|
| Ecosystem | npm |
| Package | @nestjs/platform-fastify |
| Affected versions | >= 12.0.0, < 12.0.2 and < 11.2.4 |
| Patched versions | 12.0.2 and 11.2.4 (upgrade to 12.0.3 / 11.2.5) |
| Severity | High |
| CVSS v3.1 | AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N (8.1) |
Check it with your coding agent
It reads this page and tells you if your code is affected.
Are you affected?
Ask from here. InfraStack checks the affected versions against your stack and answers in your inbox.
InfraStack checks the affected versions against your stack and answers in Slack, with the evidence and the fix.
configureUpgrade to 12.0.2 and 11.2.4
@nestjs/platform-fastify 12.0.2 for the 12.x line (the advisory recommends 12.0.3)@nestjs/platform-fastify 11.2.4 for the 11.x line (the advisory recommends 11.2.5)| CWE | CWE-436 (Interpretation Conflict), CWE-288 (Authentication Bypass Using an Alternate Path or Channel) |
On the Fastify adapter, an HTTP request that uses an absolute-form request target (GET http://host/path HTTP/1.1
instead of GET /path HTTP/1.1) reaches the route handler without running the path-scoped Nest middleware bound to
that route. Applications that enforce authentication or authorization in middleware execute the protected handler
with those checks skipped.
Any application that
@nestjs/platform-fastify, andMiddlewareConsumer.forRoutes(...) or .exclude(...), andNode's HTTP server accepts absolute-form targets, so no special server configuration is needed. Exposure is reduced when a reverse proxy in front of the application rewrites the request target to origin-form, which most do.
Where the bypassed middleware performs authentication or authorization, the result is an authentication or authorization bypass. Where it performs logging, rate limiting or body handling, those are silently skipped instead.
Fastify's router (find-my-way) resolves an absolute-form target to its path before matching, so the route handler
is dispatched normally. Two places on the middleware side matched against the raw request target instead:
@fastify/middie engine at packages/platform-fastify/adapters/middie/fastify-middie.ts.
NestJS carried this fork to apply an earlier path-decoding fix and it did not track the upstream absolute-form fix
released in @fastify/middie@9.3.4.FastifyAdapter's own re-check in createMiddlewareFactory(), which tests the middleware path regexp against
req.originalUrl.Both normalized and percent-decoded the target, but neither resolved absolute-form to a path, so the router and the middleware layer disagreed about which path was being requested.
A second, related defect contributed. Because the adapter always passes routerOptions (to install the version
constraint), Fastify did not reflect the deprecated top-level router options (ignoreTrailingSlash,
ignoreDuplicateSlashes, caseSensitive, useSemicolonDelimiter) in initialConfig.routerOptions, which is what
the middleware engine reads. Applications passing those options at the top level had middleware normalize paths
differently from the router, which widened the mismatch.
@Controller('users')
export class UsersController {
@Get()
findAll() {
return 'protected data';
}
}
@Module({ controllers: [UsersController] })
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply((req, res) => 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:
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.
Fixed in 12.0.2 and 11.2.4. Upgrading to 12.0.3 or 11.2.5 is recommended.
@fastify/middie fork was removed and the package now depends on @fastify/middie@9.3.4, which
resolves absolute-form targets before matching.find-my-way.routerOptions so the middleware engine and the
router normalize paths identically.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:
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.
Reported by ZeroVuln Labs.