T09 · Insecure Skill Coding Practices
- Location
scripts/generate.py:60- Finding
TLS Certificate and Hostname Verification Disabled for Image Downloads
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate.py, lines 60–69
Vulnerability Type: Improper TLS certificate validation
Risk Level: HighVulnerable Code
python ctx = ssl.create_default_context() ctx.check_hostname = False ctx.verify_mode = ssl.CERT_NONE req = urllib.request.Request(url) with urllib.request.urlopen(req, context=ctx) as response: with open(output_path, 'wb') as f: f.write(response.read()) return TrueTechnical Analysis
The download function explicitly disables both TLS certificate verification and hostname validation. Consequently, the HTTPS connection does not authenticate the remote image server. A forged, expired, self-signed, or otherwise untrusted certificate will be accepted.
This defeats the principal server-authentication guarantee provided by TLS and permits a network-positioned attacker to impersonate the image host. The response is then written directly to a local file without content-type, file-signature, or maximum-size validation.
Attack Path
- The Skill submits images to the Fal service and receives a generated-image URL.
- The Skill passes that URL to
download_image. - An attacker with a network interception capability redirects or intercepts the HTTPS connection.
- The attacker presents an arbitrary certificate for the destination host.
- Because certificate and hostname checks are disabled, the client accepts the connection.
- The attacker supplies arbitrary response bytes.
- Those bytes are written to the predetermined
pose_N.jpgoutput path and treated as generated output.
The absence of a response-size limit also allows the intercepted server to send an excessively large response, potentially exhausting memory or disk space.
Impact Assessment
A successful attacker can compromise the integrity of downloaded generated images, cause attacker-controlled content to be stored in the output directory ...[truncated 297 chars]
- Remediation
View remediation
Remediation Suggestions
-
Remove the settings that disable certificate and hostname verification.
-
Use the platform-default verified TLS context:
python req = urllib.request.Request(url) with urllib.request.urlopen(req, timeout=30) as response: data = response.read(MAX_IMAGE_SIZE + 1) -
Reject non-HTTPS URLs.
-
Restrict downloads to documented Fal or approved CDN hostnames where operationally possible.
-
Set connection and read timeouts.
-
Enforce a maximum response size before writing the file.
-
Validate the response
Content-Typeagainst an allowlist such asimage/jpegand verify the decoded file with a trusted image-processing library. -
Download to a temporary file and atomically move it into place only after successful validation.
-
