# Weak Password Requirements (CWE-521) The product does not require that users should have strong passwords, which makes it easier for attackers to compromise user accounts. **Stack:** JavaScript - Prevalence: उच्च बार-बार शोषित - Impact: उच्च 1 उच्च गंभीरता वाले नियम - Prevention: प्रलेखित 2 फिक्स उदाहरण **OWASP:** Identification and Authentication Failures (A07:2021-Identification and Authentication Failures) - #7 ## Description Without strong password requirements, users often choose weak, easily guessable passwords. This makes brute-force and dictionary attacks more likely to succeed. ## Prevention 1 Shoulder डिटेक्शन नियमों पर आधारित Weak Password Requirements के लिए रोकथाम रणनीतियाँ। ### JavaScript Require minimum 12 characters with complexity checks or use a password strength library ## Warning Signs - [HIGH] Password validation at ... lacks proper complexity requirements - [HIGH] password validation that lacks proper complexity requirements, making accounts vulnerable to brute f ## Consequences - विशेषाधिकार प्राप्त करना - सुरक्षा तंत्र को बायपास करना ## Mitigations - न्यूनतम पासवर्ड लंबाई लागू करें (12 या अधिक वर्ण अनुशंसित) - पासवर्डों की ज्ञात breach डेटाबेस से जाँच करें - बहु-कारक प्रमाणीकरण लागू करें ## Detection - Total rules: 2 - Languages: go, javascript, typescript ## Rules by Language ### Javascript (1 rules) - **Weak Password Policy** [HIGH]: Detects password validation that lacks proper complexity requirements, making accounts vulnerable to brute force attacks. - Remediation: Implement strong password requirements: ```javascript // ✅ SAFE - Strong password policy function validatePassword(password) { if (password.length < 12) { throw new Error('Password must be at least 12 characters'); } const hasUppercase = /[A-Z]/.test(password); const hasLowercase = /[a-z]/.test(password); const hasDigit = /\d/.test(password); const hasSpecial = /[!@#$%^&*(),.?":{}|<>]/.test(password); if (!hasUppercase || !hasLowercase || !hasDigit || !hasSpecial) { throw new Error( 'Password must contain uppercase, lowercase, digit, and special character' ); } return true; } ``` ### Typescript (1 rules) - **Weak Password Policy** [HIGH]: Detects password validation that lacks proper complexity requirements, making accounts vulnerable to brute force attacks. - Remediation: Implement strong password requirements: ```javascript // ✅ SAFE - Strong password policy function validatePassword(password) { if (password.length < 12) { throw new Error('Password must be at least 12 characters'); } const hasUppercase = /[A-Z]/.test(password); const hasLowercase = /[a-z]/.test(password); const hasDigit = /\d/.test(password); const hasSpecial = /[!@#$%^&*(),.?":{}|<>]/.test(password); if (!hasUppercase || !hasLowercase || !hasDigit || !hasSpecial) { throw new Error( 'Password must contain uppercase, lowercase, digit, and special character' ); } return true; } ```