# Use of Hard-coded Credentials (CWE-798) The product contains hard-coded credentials, such as a password or cryptographic key, which it uses for its own inbound authentication, outbound communication to external components, or encryption of internal data. **Stack:** Kubernetes - Prevalence: Wysoka Często wykorzystywana - Impact: Krytyczny 6 reguł o krytycznym poziomie - Prevention: Udokumentowane 11 przykładów poprawek **OWASP:** Identification and Authentication Failures (A07:2021-Identification and Authentication Failures) - #7 ## Description Hard-coded credentials typically create a significant hole that allows an attacker to bypass the authentication that has been configured by the product administrator. This hole might be difficult for the system administrator to detect. ## Prevention Strategie zapobiegania dla Hardcoded Credentials oparte na 1 regułach detekcji Shoulder. ### Kubernetes Use Kubernetes Secrets with secretKeyRef instead of hardcoding credentials in manifests ## Warning Signs - [CRITICAL] Secrets, passwords, or API keys are hardcoded in the Kubernetes manifest. - [CRITICAL] hardcoded secrets, passwords, or API keys in Kubernetes manifests ## Consequences - Uzyskanie uprawnień - Obejście mechanizmu ochrony ## Mitigations - Przechowuj poświadczenia poza kodem źródłowym - Korzystaj ze zmiennych środowiskowych lub bezpiecznych magazynów poświadczeń - Wdroż właściwe procedury zarządzania kluczami ## Detection - Total rules: 11 - Critical: 6 - Languages: python, dockerfile, go, javascript, typescript, yaml ## Rules by Language ### Yaml (1 rules) - **Hardcoded Secrets in Manifest** [CRITICAL]: Detects hardcoded secrets, passwords, or API keys in Kubernetes manifests. - Remediation: Use Kubernetes Secrets with valueFrom. ```yaml env: - name: DB_PASSWORD valueFrom: secretKeyRef: name: db-secret key: password ``` Learn more: https://shoulder.dev/learn/kubernetes/cwe-798/hardcoded-secrets