T09 · Insecure Skill Coding Practices
- Location
scripts/search_wechat.py:65- Finding
TLS Certificate and Hostname Verification Disabled for Sogou Requests
- Content
View full analysis
Vulnerability Details
File Location:
scripts/search_wechat.py, lines 65–67
Vulnerability Type: Improper certificate validation
Risk Level: Highpython _ssl_ctx = ssl.create_default_context() _ssl_ctx.check_hostname = False _ssl_ctx.verify_mode = ssl.CERT_NONEThe unsafe TLS context is subsequently supplied to Sogou requests, including calls at lines 98, 139, and 358–362.
Technical Analysis
The code explicitly disables both certificate-chain validation and hostname verification. Consequently, HTTPS connections made with
_ssl_ctxaccept certificates that are self-signed, expired, issued for another hostname, or supplied by an untrusted party.This defeats the authenticity guarantees of TLS. Although traffic remains encrypted against passive observers, an active network attacker can terminate the connection using an arbitrary certificate and provide attacker-controlled responses.
The affected responses are parsed as search results, cookies, and redirect information. Therefore, an attacker could manipulate research content saved by the Skill or intercept and replace Sogou session cookies. This behavior is unnecessary for the declared search functionality because Python's default verified TLS context should be used.
Attack Path
- The user runs the WeChat search script on an attacker-controlled or compromised network.
- The attacker intercepts a request to a Sogou HTTPS endpoint.
- The attacker presents an arbitrary certificate for the intercepted connection.
- The script accepts the certificate because certificate and hostname verification are disabled.
- The attacker returns forged HTML, cookies, or redirect headers.
- The script parses the forged data and may save attacker-controlled search results under
.skills-data/idea2mvp/data/search-results/. - Subsequent Agent analysis may treat the manipulated content as legitimate market-research evidence.
Impact Assessment
An active network attacker can compromise t ...[truncated 402 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the assignments to
check_hostnameandverify_mode. - Use the verified default context:
python _ssl_ctx = ssl.create_default_context()- Do not implement a fallback that disables verification after a certificate error.
- If a private certification authority is legitimately required, load only that authority through
load_verify_locations. - Validate that resolved redirect URLs use HTTPS and belong to an explicit allowlist such as
mp.weixin.qq.com. - Add automated tests confirming that self-signed certificates and hostname mismatches are rejected.
- Remove the assignments to
