# 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:** Docker - Prevalence: 高 頻繁に悪用される - Impact: クリティカル 6 件の重大度クリティカルなルール - Prevention: 文書化済み 11 件の修正例 **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 1 件の Shoulder 検出ルールに基づく Hardcoded Credentials の予防策。 ### Docker Use BuildKit secrets or runtime environment variables instead of hardcoded credentials ## Warning Signs - [CRITICAL] Dockerfile contains ...: ... - [CRITICAL] hardcoded secrets in ENV/ARG and piping curl/wget to shell ## Consequences - 権限の取得 - 保護メカニズムの回避 ## Mitigations - 資格情報はソースコードの外に保管する - 環境変数または安全な資格情報ストアを使用する - 適切な鍵管理手順を実装する ## Detection - Total rules: 11 - Critical: 6 - Languages: python, dockerfile, go, javascript, typescript, yaml ## Rules by Language ### Dockerfile (1 rules) - **Docker Secrets and Security Best Practices** [CRITICAL]: Detects hardcoded secrets in ENV/ARG and piping curl/wget to shell. - Remediation: Use BuildKit secrets instead of hardcoding credentials. ```dockerfile RUN --mount=type=secret,id=token \ cat /run/secrets/token ``` Learn more: https://shoulder.dev/learn/docker/cwe-798/secrets-security