T09 · Insecure Skill Coding Practices
- Location
assets/imagegen.py:192- Finding
API Key Disclosure Through Unvalidated Server-Supplied Download URLs
- Content
View full analysis
1 else f"{prefix}{ext}" filepath = os.path.join(output_dir, filename) step(f"Downloading {i}/{total}: {filename}") try: resp = session.get(url, stream=True, timeout=120) ``` The same session has the API credential configured as a default header: ```python session = requests.Session() session.verify = True session.headers.update({ "Content-Type": "application/json", "X-API-KEY": api_key, }) ``` ### Technical Analysis The application places `X-API-KEY` in the default headers of a shared `requests.Session`. It then uses that session to fetch URLs returned in the remote API's `imagePaths` field. No validation restricts download URLs to HTTPS or to trusted RedFox-controlled hosts. As a result, the default `X-API-KEY` header can be transmitted to an arbitrary host selected through a malicious or compromised API response. Redirect behavior also requires explicit hardening because a trusted-looking URL may redirect to another origin. Uploading a selected image and submitting a prompt to RedFox are necessary for the declared image-generation functionality. Sending the API credential to arbitrary image-hosting origins is not necessary and exceeds minimum privilege. ### Attack Path 1. An atta ...[truncated 1266 chars]- Remediation
View remediation
