# Improper Certificate Validation (CWE-295) The product does not validate, or incorrectly validates, a certificate. **Stack:** Python - Prevalence: 中 3 言語をカバー - Impact: ハイ 4 件の重大度ハイのルール - Prevention: 文書化済み 4 件の修正例 **OWASP:** Identification and Authentication Failures (A07:2021-Identification and Authentication Failures) - #7 ## Description When a certificate is invalid or malicious, it might allow an attacker to spoof a trusted entity by interfering in the communication path between the host and client. ## Prevention 2 件の Shoulder 検出ルールに基づく Improper Certificate Validation の予防策。 ### Python Keep SSL certificate verification enabled; use custom CA bundles for internal certs Keep SSL verification enabled (the default) or use custom CA bundles ## Warning Signs - [HIGH] disabled SSL/TLS certificate validation ## Consequences - 保護メカニズムの回避 - アプリケーションデータの読み取り - アプリケーションデータの変更 ## Mitigations - 証明書は慎重に管理し、引き続き有効であることを確認する - 証明書ピン留めを使用する場合は、正しく実装されていることを確認する - SSL/TLS クライアント証明書検証を適切に使用する ## Detection - Total rules: 4 - Languages: go, javascript, typescript, python ## Rules by Language ### Python (2 rules) - **SSL/TLS Certificate Validation Disabled** [HIGH]: Detects disabled SSL/TLS certificate validation. Disabling certificate validation makes connections vulnerable to man-in-the-middle attacks. - Remediation: Keep SSL certificate verification enabled (default behavior). ```python import requests # Certificate verification is enabled by default response = requests.get('https://api.example.com') # For custom CA certificates response = requests.get('https://api.example.com', verify='/path/to/ca-bundle.crt') ``` Learn more: https://shoulder.dev/learn/python/cwe-295/certificate-validation-bypass - **SSL/TLS Certificate Verification Disabled** [HIGH]: Detects disabled SSL/TLS certificate verification in HTTP requests. This makes the application vulnerable to man-in-the-middle (MITM) attacks where attackers can intercept and modify encrypted traffic. Always verify SSL certificates. - Remediation: Keep SSL verification enabled (verify=True is the default). ```python import requests response = requests.get(url, verify=True, timeout=10) # For custom CA certificates: response = requests.get(url, verify='/path/to/ca-bundle.crt') ``` Learn more: https://shoulder.dev/learn/python/cwe-295/ssl-verification-disabled