T09 · Insecure Skill Coding Practices
- Location
scripts/generate.py:67- Finding
Unbounded Remote Request and Response Processing
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate.py, lines 67 and 80–82
Vulnerability Type: Missing HTTP timeout and response-size limits
Risk Level: MediumVulnerable Code:
python response = requests.post(url, headers=headers, json=data) # ... image_data = base64.b64decode(part['inlineData']['data']) with open(args.output, "wb") as f: f.write(image_data)Technical Analysis
The outbound HTTP request is made without connect or read timeouts. A remote endpoint that accepts the connection but delays or never completes its response can therefore block the process indefinitely.
The response is also parsed and Base64-decoded without limits on the response body, encoded image field, or decoded image size. Because the response content is controlled by the remote API, a compromised or malfunctioning endpoint could supply excessive data. Buffering the HTTP response, parsing the JSON, decoding the Base64 value, and writing the resulting bytes can consume substantial memory and disk space.
Attack Path
- A user invokes the documented image-generation script.
- The script submits the prompt and optional images to the ZenMux endpoint.
- A compromised or malfunctioning endpoint either stalls the connection or returns an excessively large JSON response containing Base64 data.
- Because no timeout is configured, a stalled response can leave the process blocked indefinitely.
- For an oversized response, the script buffers, parses, and decodes the remotely supplied data without enforcing resource limits.
- The process may exhaust memory, consume excessive disk space, or become unavailable.
Impact Assessment
The issue primarily affects availability. Exploitation can hang the process or exhaust resources available to the invoking user, including memory and writable disk capacity. The decoded content is written with the privileges of the user running the script and to the us ...[truncated 212 chars]
- Remediation
View remediation
Remediation Suggestions
-
Configure explicit connect and read timeouts, for example:
python response = requests.post( url, headers=headers, json=data, timeout=(10, 120), ) response.raise_for_status() -
Enforce a maximum acceptable HTTP response size before parsing or decoding it.
-
Reject Base64 image fields whose encoded length exceeds a documented limit.
-
Estimate and validate the decoded size before calling
base64.b64decode. -
Decode and write data using bounded or streaming processing where supported.
-
Validate the returned MIME type and image structure before accepting the content.
-
Handle timeout, size-limit, JSON-parsing, and Base64-decoding failures separately, ensuring partial output files are removed.
-
Consider checking available disk space and writing to a temporary file before atomically replacing the requested output.
-
