T09 · Insecure Skill Coding Practices
- Location
scripts/query_lightrag.py:77- Finding
TLS Certificate and Hostname Verification Disabled
- Content
View full analysis
Vulnerability Details
File Location:
scripts/query_lightrag.py, lines 77–80
Vulnerability Type: Improper certificate validation
Risk Level: HighVulnerable Code:
python # Create unverified context to bypass SSL issues ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONETechnical 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-Keyheader and sensitive query text, this flaw compromises both request confidentiality and response integrity.Attack Path
- A user configures an HTTPS LightRAG endpoint and an API key.
- The user invokes the
querycommand. - An attacker with a network interception position redirects or intercepts the connection.
- The attacker presents an untrusted or hostname-mismatched certificate.
- The script accepts the certificate because certificate and hostname verification are disabled.
- The attacker captures the API key and query body.
- The attacker may return a manipulated JSON response containing malicious or misleading context.
- 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
View remediation
Remediation Suggestions
- Remove the assignments to
check_hostnameandverify_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.
- Remove the assignments to
