T09 · Insecure Skill Coding Practices
- Location
scripts/generate_logo.py:71- Finding
DashScope API Key Exposed Through Process Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate_logo.py, lines 71–77
Vulnerability Type: Sensitive credential exposure through process arguments
Risk Level: MediumVulnerable Code
python result = subprocess.run([ "curl", "-s", "--max-time", "120", API_URL, "-H", "Content-Type: application/json", "-H", f"Authorization: Bearer {api_key}", "-d", json.dumps(payload, ensure_ascii=False) ], capture_output=True, text=True, timeout=150)Technical Analysis
The DashScope API key is interpolated directly into a command-line argument passed to
curl. Althoughsubprocess.run()uses an argument array rather than a shell and therefore does not introduce shell command injection here, the bearer credential remains visible in the spawned process's argument list while the request is running.Depending on the operating system and process-isolation configuration, command-line arguments may be observable through process-monitoring utilities or process metadata such as
/proc. A local process with sufficient visibility—including another process running under the same account—could capture the authorization header and recover the API key.Passing the key through the
--api-keyCLI option can also expose it in the Python process's own command line before it is forwarded tocurl.Attack Path
- A victim invokes the Skill with a valid DashScope API key.
- The script launches
curland embeds the key in anAuthorization: Bearer ...command-line argument. - While the request is active, a local attacker or compromised process with permission to inspect the victim's process metadata monitors process argument lists.
- The attacker extracts the bearer token from the
curlarguments. - The attacker uses the recovered key to make unauthorized requests to the DashScope API until the credential is revoked or expires.
This attack requires local process visibility an ...[truncated 585 chars]
- Remediation
View remediation
Remediation Suggestions
- Replace the external
curlinvocation with an in-process HTTPS client that supplies the authorization header through the client API rather than process arguments. - Avoid accepting secrets through command-line options where possible. Prefer a protected environment variable, standard input, or a dedicated secret-management service.
- If
curlmust be retained, provide sensitive configuration through a protected temporary configuration stream or file instead of command-line arguments. - Create any temporary credential-bearing file with owner-only permissions, such as
0600, and remove it reliably in afinallyblock. - Ensure error messages and diagnostic logs never include the authorization header or API key.
- Revoke and rotate API keys that may previously have been exposed through process monitoring.
- Apply least privilege, usage quotas, and billing alerts to DashScope API credentials.
- Replace the external
