Packages / @nestjs/platform-fastify / Security
Nest has a Fastify URL Encoding Middleware Bypass (TOCTOU)
Affected releases · @nestjs/platform-fastify
- 11.x11.0.0 – 11.1.10Fixed in 11.1.11
- 10.x10.0.0 – 10.4.22No fix on this line yet
- 9.x and older6.0.0 – 9.4.3No fix, no longer updated
On 11.x, the newest line:
npm install @nestjs/platform-fastify@11.1.11Not affected
12.0.0 – 12.2.0
10 releases, latest
Affected
11.0.0 – 11.1.10
33 releases
Fixed
11.1.11 – 11.2.7
27 releases
Affected
10.0.0 – 10.4.22
55 releases
Affected
9.0.0 – 9.4.3
37 releases
Affected
8.0.0 – 8.4.7
32 releases
Affected
7.0.0 – 7.6.18
51 releases
Affected
6.0.0 – 6.11.11
67 releases
Is your project affected?
Paste your package.json, or type the range you declare for @nestjs/platform-fastify. It is read in your browser and sent nowhere.
What happens
A NestJS application is vulnerable if it meets all of the following criteria:
Platform: Uses
@nestjs/platform-fastify.Security Mechanism: Relies on
NestMiddleware(viaMiddlewareConsumer) for security checks (authentication, authorization, etc.), or throughapp.use()Routing: Applies middleware to specific routes using string paths or controllers (e.g.,
.forRoutes('admin')). Example Vulnerable Config:
// app.module.ts
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
consumer
.apply(AuthMiddleware) // Security check
.forRoutes('admin'); // Vulnerable: Path-based restriction
}
}Attack Vector:
Target Route:
/adminMiddleware Path:
adminAttack Request:
GET /%61dminResult: Middleware is skipped (no match on
%61dmin), but controller for/adminis executed.
Consequences:
Authentication Bypass: Unauthenticated users can access protected routes.
Authorization Bypass: Restricted administrative endpoints become accessible to lower-privileged users.
Input Validation Bypass: Middleware performing sanitization or validation can be skipped.
Patches
Patched in @nestjs/platform-fastify@11.1.11
Resources
Credit goes to Hacktron AI for reporting this issue.