T09 · Insecure Skill Coding Practices
- Location
scripts/xiaxiayouhui.py:28- Finding
TLS certificate validation is disabled for the comparison service
- Content
View full analysis
Vulnerability Details
File Location:
scripts/xiaxiayouhui.py, lines 28–31 and 39–45
Vulnerability Type: Improper TLS certificate validation
Risk Level: MediumVulnerable code:
python def _ssl_ctx() -> ssl.SSLContext: ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE return ctx def _get(path: str, params: dict[str, Any]) -> dict[str, Any]: """Standard-library GET returning JSON.""" query = urllib.parse.urlencode({k: v for k, v in params.items() if v is not None}) url = f"{BASE_URL}{path}" + (f"?{query}" if query else "") req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"}) try: with urllib.request.urlopen( req, timeout=TIMEOUT, context=_ssl_ctx(), ) as resp: return json.loads(resp.read().decode("utf-8"))Technical Analysis
The client deliberately disables both certificate-chain validation and hostname verification. Although
BASE_URLuses HTTPS, the resulting connection does not authenticatexiaxiayouhui.xyz.This code is reached by all operations implemented through
_get, including comparison searches, daily deals, product-link parsing, and local coupon queries. A network-positioned attacker able to intercept traffic can present any certificate and impersonate the service.The response is parsed as trusted JSON and subsequently formatted into user-facing product names, prices, coupon descriptions, merchant names, and service errors. No cryptographic response authentication compensates for the disabled TLS checks.
Attack Path
- The user or agent invokes
search,daily,parse, orlocal. - The script constructs an HTTPS request to
xiaxiayouhui.xyz. - A network-positioned attacker intercepts the connection and supplies an arbitrary TLS certificate.
- The client accepts that certificate because hostname and certificate verification are disabled ...[truncated 866 chars]
- The user or agent invokes
- Remediation
View remediation
Remediation Suggestions
- Remove the custom
_ssl_ctx()function and allowurllibto use its default verified TLS context:
python with urllib.request.urlopen(req, timeout=TIMEOUT) as resp: ...- Alternatively, use
ssl.create_default_context()without modifyingcheck_hostnameorverify_mode. - Do not add a fallback that retries with certificate validation disabled.
- Ensure the runtime uses a maintained CA trust store.
- Treat certificate failures as hard errors and return a clear failure message.
- Add tests confirming that self-signed, expired, and hostname-mismatched certificates are rejected.
- Remove the custom
