T09 · Insecure Skill Coding Practices
- Location
scripts/download_diagram.py:26- Finding
TLS Certificate and Hostname Verification Disabled
- Content
View full analysis
Vulnerability Details
File Location:
scripts/download_diagram.py, lines 26–37
Vulnerability Type: Improper certificate validation
Risk Level: HighVulnerable Code
python def download_file(url: str, output_path: str) -> str: """Download a file from URL to output_path. Returns the output_path on success.""" ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE req = urllib.request.Request(url, headers={"User-Agent": "EdrawMax-Skill/2.0"}) try: with urllib.request.urlopen(req, context=ctx, timeout=60) as resp: data = resp.read()Technical Analysis
The downloader explicitly disables both TLS certificate-chain verification and hostname verification. Consequently, an HTTPS connection does not authenticate the remote server. Any certificate, including a self-signed certificate controlled by an attacker, will be accepted.
The timeout only limits how long the request may wait; it does not restore server authentication or protect response integrity. Although the diagram API is expected to return legitimate object-storage URLs, the script cannot determine whether downloaded content genuinely originated from the intended server.
Attack Path
- A user requests a diagram, and the service returns PNG and SVG download URLs.
- The skill invokes
download_diagram.pywith those URLs. - An attacker positioned on the network path intercepts an HTTPS download.
- The attacker presents an arbitrary certificate and impersonates the remote host.
- The script accepts the certificate because certificate and hostname checks are disabled.
- The attacker returns substituted PNG or SVG bytes.
- The substituted content is written locally and presented as a trusted diagram.
Impact Assessment
A network-positioned attacker can compromise the confidentiality and integrity of downloaded diagram data. The a ...[truncated 536 chars]
- Remediation
View remediation
Remediation Suggestions
-
Preserve the secure defaults of Python's TLS context:
python ctx = ssl.create_default_context()Remove both of the following assignments:
python ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE -
Fail closed when certificate verification or hostname validation fails. Do not retry using an insecure context.
-
Require HTTPS URLs and allowlist the expected EdrawMax object-storage domains.
-
Validate the destination after every redirect so an approved host cannot redirect to an untrusted host or non-HTTPS destination.
-
Consider certificate pinning only if the service has a reliable certificate-rotation process. Standard platform trust-store validation is preferable to insecure custom verification.
-
Add automated tests confirming that self-signed certificates, expired certificates, certificates for another hostname, and invalid certificate chains are rejected.
-
