# Improper Certificate Validation (CWE-295) The product does not validate, or incorrectly validates, a certificate. **Stack:** Go - 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 基于 1 条 Shoulder 检测规则的 Improper Certificate Validation 预防策略。 ### Go Use TLS 1.2+ minimum version and always verify certificates ## Warning Signs - [HIGH] TLS configuration disables security features or uses weak settings ## Consequences - 绕过保护机制 - 读取应用程序数据 - 修改应用程序数据 ## Mitigations - 对证书进行细致管理并检查,以确保其仍然有效 - 如果使用证书固定 (pinning),请确保实现正确 - 正确使用 SSL/TLS 客户端证书验证 ## Detection - Total rules: 4 - Languages: go, javascript, typescript, python ## Rules by Language ### Go (1 rules) - **Insecure TLS/SSL Configuration** [HIGH]: TLS config uses InsecureSkipVerify, weak TLS version, or deprecated ciphers. - Remediation: Set MinVersion to TLS 1.2+ and never skip certificate verification. ```go tlsConfig := &tls.Config{ MinVersion: tls.VersionTLS12, InsecureSkipVerify: false, // Always verify certificates } ``` Learn more: https://shoulder.dev/learn/go/cwe-295/insecure-tls-config