NestJS Sensitive Route Missing Guard
Description
Controllers without @UseGuards on sensitive operations allow unauthorized access to create, update, delete, and admin endpoints.
What Shoulder detects
How to fix
Add @UseGuards decorator to sensitive endpoints.
```typescript
import { UseGuards } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
@Controller('users')
export class UserController {
@Delete(':id')
@UseGuards(AuthGuard('jwt'))
deleteUser(@Param('id') id: string) {
return this.userService.delete(id);
}
}
```
Learn more: https://shoulder.dev/learn/typescript/cwe-285/missing-route-guard
Applies to
Languages
Frameworks
nestjs
References
Scan for this issue
Detect with Shoulder CLI
npx @shoulderdev/cli trust --rule=nestjs-missing-route-guard .