T09 · Insecure Skill Coding Practices
- Location
scripts/generate_cover_image.py:46- Finding
Caller-Controlled API Endpoint Can Receive Sensitive Images and Credentials
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate_cover_image.py, lines 46–70 and 112
Vulnerability Type: Unrestricted external API destination and sensitive-data disclosure
Risk Level: Highpython client = OpenAI( api_key=get_config_value("qdd"), base_url=base_url ) print(f"Encoding base image from {base_image_path}...") base64_image = encode_image_to_base64(base_image_path) final_prompt = prompt_template.format(text_to_add=text_to_add) print("Using provided prompt...", final_prompt) print("Sending request to the image generation API...") try: response = client.chat.completions.create( model=model, messages=[ { "role": "user", "content": [ {"type": "text", "text": final_prompt}, { "type": "image_url", "image_url": { "url": f"data:image/png;base64,{base64_image}" } } ] } ],python parser.add_argument("--base-url", required=True, help="The API base URL.")Technical Analysis
The script reads the complete user-selected image, Base64-encodes it, and transmits it together with the generated prompt to an OpenAI-compatible endpoint. Uploading an image is necessary for the declared AI image-editing operation. Base64 is normal transport encoding here and is not, by itself, evidence of covert exfiltration.
The security issue is that
base_urlis supplied directly by the caller without an HTTPS requirement, trusted-host allowlist, redirect policy, or user confirmation. The OpenAI client also uses the configured API key when contacting this destination. Consequently, a manipulated invocation can direct sensitive image content, prompts, and authentication material to an attacker-controlled se ...[truncated 1198 chars]- Remediation
View remediation
Remediation Suggestions
- Remove caller-controlled endpoint selection unless custom providers are an explicit functional requirement.
- Pin the client to a documented, trusted HTTPS API origin.
- If multiple providers must be supported, enforce an exact hostname allowlist and reject non-HTTPS URLs, embedded credentials, IP literals, unexpected ports, and untrusted redirects.
- Use a separate credential for each approved provider and never send one provider's credential to another provider.
- Display the selected destination and require explicit user approval before uploading an image.
- Document that the full image and prompt leave the local system.
- Apply request-size limits and validate that the selected input is a supported image before transmission.
- Add automated tests proving that unapproved schemes, hosts, ports, and redirect targets are rejected.
