T09 · Insecure Skill Coding Practices
- Location
scripts/nim_call.py:37- Finding
TLS Certificate and Hostname Verification Disabled
- Content
View full analysis
Vulnerability Details
File Location:
scripts/nim_call.py, lines 37–43
Vulnerability Type: Improper Certificate Validation / CWE-295
Risk Level: HighVulnerable Code
python ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE try: req = urllib.request.Request(url, data=json.dumps(data).encode(), headers=headers) with urllib.request.urlopen(req, context=ctx) as response:Technical Analysis
The script creates a TLS context but then explicitly disables both hostname validation and certificate-chain verification. It passes that insecure context to
urllib.request.urlopen()when submitting requests to the NVIDIA API.Consequently, the client accepts an arbitrary certificate instead of verifying that the remote server controls a certificate valid for
integrate.api.nvidia.comand issued by a trusted certificate authority. HTTPS encryption alone does not authenticate the endpoint under these settings.Because the request carries the
NVIDIA_API_KEYas a bearer credential and includes the complete user prompt, a network-positioned attacker can impersonate the API endpoint. This is particularly relevant to the documented workflow of sending long files or project material for external processing.Attack Path
- A user configures
NVIDIA_API_KEYand invokesscripts/nim_call.pywith a prompt. - The script constructs an HTTPS request containing the bearer API key and prompt.
- An attacker obtains a network interception position, such as through a hostile Wi-Fi access point, compromised proxy, poisoned DNS path, or compromised network infrastructure.
- The attacker presents a forged or self-signed certificate for the NVIDIA API hostname.
- The script accepts the certificate because certificate and hostname validation are disabled.
- The attacker decrypts or proxies the request, obtaining the API key and submitted prompt.
- The attacker may also return a forged model respo ...[truncated 784 chars]
- A user configures
- Remediation
View remediation
Remediation Suggestions
Retain Python's default certificate and hostname verification. Remove both insecure assignments:
python ctx = ssl.create_default_context() try: req = urllib.request.Request( url, data=json.dumps(data).encode(), headers=headers ) with urllib.request.urlopen(req, context=ctx) as response: result = json.loads(response.read().decode())Alternatively, omit the explicit context and allow
urlopen()to use its verified default HTTPS handling:python with urllib.request.urlopen(req) as response:Additional hardening measures:
- Never set
verify_modetossl.CERT_NONEin production code. - Never disable
check_hostnamefor credential-bearing HTTPS requests. - If a private trust store is required, load a controlled CA bundle with
ssl.create_default_context(cafile=...)rather than disabling verification. - Add a finite request timeout to limit stalled connections.
- Add an automated test asserting that an untrusted or hostname-mismatched certificate causes the request to fail.
- Rotate the NVIDIA API key if this implementation has been used over an untrusted network.
- Never set
