T09 · Insecure Skill Coding Practices
- Location
scripts/generate.py:63- Finding
Remote API credentials and image prompts may be transmitted over plaintext HTTP
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate.py:63-88
Vulnerability Type: Plaintext transmission of sensitive data
Risk Level: MediumVulnerable code:
python url = f"{server.rstrip('/')}/v1/images/generations" body: dict = { "prompt": prompt, "size": size, "n": 1, "response_format": "b64_json", } if negative_prompt: body["negative_prompt"] = negative_prompt if steps is not None: body["num_inference_steps"] = steps if guidance_scale is not None: body["guidance_scale"] = guidance_scale if seed is not None: body["seed"] = seed data = json.dumps(body).encode("utf-8") headers = {"Content-Type": "application/json"} if api_key: headers["Authorization"] = f"Bearer {api_key}" req = urllib.request.Request(url, method="POST", headers=headers, data=data)The documentation also explicitly demonstrates a remote plaintext endpoint:
bash python3 {baseDir}/scripts/generate.py --prompt "photo" --server http://192.168.1.100:30000 --out ./my-image.pngTechnical Analysis
The server address is supplied directly by the user and is not validated to ensure that remote connections use HTTPS. When an API key is configured, it is placed in the
Authorizationheader regardless of the selected URL scheme. The request body contains the image prompt, negative prompt, dimensions, seed, and generation settings.Sending this request to a non-loopback HTTP endpoint exposes the bearer credential and request content to any party able to observe or alter traffic between the client and server. The default loopback endpoint is appropriate for a genuinely local service, but the documented remote-server mode causes sensitive information to cross the network without transport encryption.
Network communication is necessary for the declared image-generation functionality. However, permitting authenticated remote communication over plaintext HTTP e ...[truncated 1373 chars]
- Remediation
View remediation
Remediation Suggestions
- Require
https://for every non-loopback server address. - Permit plaintext HTTP only for verified loopback destinations such as
127.0.0.1,::1, andlocalhost. - If remote plaintext HTTP must remain available for exceptional development use, require an explicit opt-in flag and display a clear warning. Reject sending an API key unless TLS is enabled.
- Update
SKILL.mdso all remote-server examples use HTTPS. - Parse the URL with
urllib.parse.urlparseand validate its scheme and hostname before constructing the request. - Continue using standard certificate verification for HTTPS and do not introduce options that silently disable certificate validation.
- Consider allowing administrators to restrict requests to an approved hostname or endpoint allowlist.
- Require
