# Use of Hard-coded Password (CWE-259) The product contains a hard-coded password, which it uses for its own inbound authentication or for outbound communication to external components. - Prevalence: Élevée Fréquemment exploitée - Impact: Élevé 1 règles de sévérité élevée - Prevention: Documentée 1 exemples de correctifs **OWASP:** Identification and Authentication Failures (A07:2021-Identification and Authentication Failures) - #7 ## Description Hard-coded passwords are easily discovered through reverse engineering and cannot be changed without modifying the software. This creates a significant security risk as the password becomes public knowledge. ## Prevention Stratégies de prévention pour Hardcoded Password basées sur 1 règles de détection Shoulder. ### JavaScript Load passwords from environment variables instead of hardcoding ## Warning Signs - [HIGH] Hardcoded weak password detected: ... This password is easily guessable and should never be used in production. - [HIGH] hardcoded weak passwords in database connections and configuration ## Consequences - Obtenir des privilèges - Contourner le mécanisme de protection ## Mitigations - Stockez les mots de passe dans des fichiers de configuration sécurisés ou des variables d'environnement - Utilisez un système sécurisé de gestion des informations d'identification - Générez des mots de passe aléatoires lors de l'installation ## Detection - Total rules: 1 - Languages: javascript, typescript ## Rules by Language ### Javascript (1 rules) - **Hardcoded Weak Password** [HIGH]: Detects hardcoded weak passwords in database connections and configuration. Common weak passwords like "password", "admin", "root", "secret", etc. are easily guessed and should never be hardcoded in source code. This rule complements the high-entropy secrets detection by catching simple, well-known weak passwords that entropy-based detection would miss. - Remediation: Move credentials to environment variables: Before: password: 'password' After: password: process.env.DB_PASSWORD Then set DB_PASSWORD in your environment or .env file. ### Typescript (1 rules) - **Hardcoded Weak Password** [HIGH]: Detects hardcoded weak passwords in database connections and configuration. Common weak passwords like "password", "admin", "root", "secret", etc. are easily guessed and should never be hardcoded in source code. This rule complements the high-entropy secrets detection by catching simple, well-known weak passwords that entropy-based detection would miss. - Remediation: Move credentials to environment variables: Before: password: 'password' After: password: process.env.DB_PASSWORD Then set DB_PASSWORD in your environment or .env file.