T09 · Insecure Skill Coding Practices
- Location
scripts/generate.py:57- Finding
API Key Exposed Through Subprocess Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate.py, lines 57-69
Vulnerability Type: Sensitive credential exposure through process arguments
Risk Level: MediumVulnerable Code:
python curl_cmd = [ "curl", "-s", "-X", "POST", f"{API_BASE_URL}/video/submit", "-H", f"Authorization: Bearer {api_key}", "-H", "Content-Type: application/json", "-d", json.dumps(data), "--max-time", "30" ] try: result = subprocess.run(curl_cmd, capture_output=True, text=True)Technical Analysis
The SiliconFlow bearer token is embedded directly in the argument list passed to the
curlsubprocess. On systems where process arguments are visible through process inspection facilities, monitoring tools, audit logs, or process-listing utilities, another local user or process may observe the completeAuthorizationheader while the request is running.Using an argument list avoids shell-command injection, but it does not protect sensitive values from process metadata exposure. The request should instead be made through an in-process HTTPS client so that the credential is carried only in application memory and the encrypted network request.
Attack Path
- An attacker obtains local process-observation capability on the machine running the skill.
- The victim invokes the video-generation script with a valid SiliconFlow API key.
- The script starts
curlwithAuthorization: Bearer <API_KEY>in its command-line arguments. - The attacker monitors process metadata and captures the authorization argument while
curlis running. - The attacker reuses the captured credential to make unauthorized SiliconFlow API requests.
Exploitation requires local process visibility or access to tooling that records command-line arguments. It is not remotely exploitable solely through the prompt or image URL.
Impact Assessment
A successful attacker can obtain the Sili ...[truncated 329 chars]
- Remediation
View remediation
Remediation Suggestions
- Replace the
curlsubprocess with a maintained in-process HTTPS client, such as Python'surllib.requestor a pinned HTTP library. - Supply the bearer token through the HTTP client's header API rather than through child-process arguments.
- Configure explicit connection and response timeouts and validate HTTP status codes and response content.
- Ensure exception messages, debug logs, and API error handling never include authorization headers or the raw API key.
- If use of
curlis unavoidable, provide sensitive configuration through a protected mechanism that does not expose it in process arguments, and restrict any temporary configuration file to owner-only permissions with reliable cleanup. - Rotate the API key if there is reason to believe process arguments have already been collected or logged.
- Replace the
