# Missing Authentication for Critical Function (CWE-306) The product does not perform any authentication for functionality that requires a provable user identity or consumes a significant amount of resources. **Stack:** JavaScript - Prevalence: उच्च बार-बार शोषित - Impact: उच्च 6 उच्च गंभीरता वाले नियम - Prevention: प्रलेखित 6 फिक्स उदाहरण **OWASP:** Identification and Authentication Failures (A07:2021-Identification and Authentication Failures) - #7 ## Description As data traverses trust boundaries, the data should be validated before being processed. When authentication is not applied to critical functions, attackers can invoke these functions without proving their identity. ## Prevention ### JavaScript Add @UseGuards decorator with authentication guard at controller or method level ## Warning Signs - [HIGH] NestJS endpoint has no @UseGuards() decorator for authentication ## Consequences - विशेषाधिकार प्राप्त करना - एप्लिकेशन डेटा पढ़ना - एप्लिकेशन डेटा संशोधित करना - अनधिकृत कोड निष्पादित करना ## Mitigations - सॉफ़्टवेयर को विभिन्न विश्वास स्तरों वाले कॉम्पोनेंट्स में विभाजित करें - सुरक्षा-गंभीर कार्यक्षमता वाले सभी क्षेत्रों की पहचान करें और उन सभी के लिए प्रमाणीकरण अनिवार्य करें - सुनिश्चित करें कि उचित पहुँच नियंत्रण लागू किए गए हैं ## Detection - Total rules: 6 - Languages: python, go, typescript ## Rules by Language ### Typescript (1 rules) - **NestJS Endpoint Missing Authentication Guard** [HIGH]: Endpoints without @UseGuards or @Public decorators are accessible to unauthenticated users, enabling unauthorized access. - Remediation: Add @UseGuards decorator at controller or method level. ```typescript import { UseGuards } from '@nestjs/common'; import { JwtAuthGuard } from '../auth/jwt-auth.guard'; @Controller('users') @UseGuards(JwtAuthGuard) export class UsersController { @Get(':id') findOne(@Param('id') id: string) { return this.usersService.findOne(id); } } ``` Learn more: https://shoulder.dev/learn/typescript/cwe-306/missing-auth-guard