T09 · Insecure Skill Coding Practices
- Location
scripts/download_diagram.py:27- Finding
TLS Certificate and Hostname Verification Disabled
- Content
View full analysis
Vulnerability Details
File Location:
scripts/download_diagram.py, lines 27–35
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:Technical Analysis
The downloader explicitly disables both TLS certificate verification and hostname validation. Consequently, an HTTPS connection succeeds even when the server presents an expired, self-signed, forged, or otherwise untrusted certificate.
This removes the authenticity and integrity guarantees normally provided by HTTPS. Although the diagram-generation API is contacted over HTTPS, the PNG and SVG resources returned by that API are downloaded through this insecure TLS context. The weakness applies to every HTTPS host passed to
download_file().SVG files are particularly relevant because they are active document formats and may contain external references, scripts, or other dangerous elements depending on the application used to open or render them.
Attack Path
- The Skill submits a diagram request and receives PNG and SVG download URLs.
- The download script connects to those URLs using a TLS context configured with
CERT_NONE. - An attacker in a position to intercept network traffic presents a forged certificate.
- The script accepts the certificate without warning.
- The attacker substitutes the expected image with attacker-controlled PNG, SVG, or arbitrary file content.
- The substituted file is written locally and its path is presented to the user as a generated diagra ...[truncated 533 chars]
- Remediation
View remediation
Remediation Suggestions
-
Remove the statements that disable hostname and certificate verification.
-
Use Python's default verified TLS configuration:
python ctx = ssl.create_default_context() with urllib.request.urlopen(req, context=ctx, timeout=60) as resp: ... -
Fail closed when certificate validation fails; do not retry with an insecure context.
-
Keep the operating system and Python certificate-authority stores current.
-
Combine proper TLS verification with an allowlist of expected EdrawMax and OSS hostnames.
-
Validate the downloaded file type and sanitize SVG content before exposing the file to users.
-
