T09 · Insecure Skill Coding Practices
Error
- Location
- scripts/query_lightrag.py:77
- Finding
- TLS Certificate and Hostname Verification Disabled## Vulnerability Details **File Location**: `scripts/query_lightrag.py`, lines 77–80 **Vulnerability Type**: Improper certificate validation **Risk Level**: High **Vulnerable Code**: ```python # Create unverified context to bypass SSL issues ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE ``` ### Technical Analysis The script explicitly disables both TLS certificate-chain validation and hostname verification for every HTTPS request. Consequently, it cannot verify that the remote endpoint is the configured LightRAG server. An attacker capable of intercepting network traffic can present an arbitrary certificate without causing the connection to fail. Because requests may contain an `X-API-Key` header and sensitive query text, this flaw compromises both request confidentiality and response integrity. ### Attack Path 1. A user configures an HTTPS LightRAG endpoint and an API key. 2. The user invokes the `query` command. 3. An attacker with a network interception position redirects or intercepts the connection. 4. The attacker presents an untrusted or hostname-mismatched certificate. 5. The script accepts the certificate because certificate and hostname verification are disabled. 6. The attacker captures the API key and query body. 7. The attacker may return a manipulated JSON response containing malicious or misleading context. 8. That content is printed directly or supplied to a downstream writing workflow. ### Impact Assessment A network-positioned attacker may obtain LightRAG API credentials, read potentially sensitive knowledge-base queries, modify server responses, and inject attacker-controlled material into downstream agent tasks. The vulnerability does not directly grant local operating-system privileges, but it can provide access equivalent to the compromised API key and undermine the integrity of generated output.
- Remediation
- ## Remediation Suggestions - Remove the assignments to `check_hostname` and `verify_mode`. - Use Python's default verified TLS context: ```python ctx = ssl.create_default_context() ``` - For private certificate authorities, accept an explicitly configured CA bundle and load it with `ssl.create_default_context(cafile=...)`. - Do not provide a global “disable verification” option. If an exceptional development-only override is unavoidable, require an explicit flag, emit a prominent warning, and prohibit its use when an API key is configured. - Add tests confirming that self-signed, expired, and hostname-mismatched certificates are rejected.
