T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/generate.sh:37
- Finding
- API Key Exposed Through curl Process Arguments## Vulnerability Details **File Location**: `scripts/generate.sh`, lines 37-40 **Vulnerability Type**: Sensitive credential exposure through command-line arguments **Risk Level**: Medium ```bash # Call Zhipu API RESULT=$(curl -s --proto =https --tlsv1.2 -m 60 -X POST "https://open.bigmodel.cn/api/paas/v4/images/generations" \ -H "Authorization: Bearer $KEY" \ -H "Content-Type: application/json" \ ``` ### Technical Analysis The shell expands `$KEY` before launching `curl`, placing the complete bearer token inside the `Authorization` header passed as a command-line argument. While the request is active, the expanded header may be visible through process inspection interfaces or captured by process-monitoring and auditing software. Exploitation requires local process-inspection access, and operating-system restrictions may limit which users can inspect another user's processes. Nevertheless, command-line arguments are not an appropriate channel for secrets because they can be retained or exposed outside the intended process. `SKILL.md` acknowledges this process-list visibility, but documentation does not mitigate the underlying credential exposure. ### Attack Path 1. A victim exports a valid `ZHIPU_API_KEY` and runs `scripts/generate.sh`. 2. The script expands `$KEY` into the `curl` command-line argument containing the Authorization header. 3. During the API request, a local user or monitoring service with sufficient process-inspection access reads or records the curl argument list. 4. The observer extracts the bearer token from the captured header. 5. The stolen key is reused to authenticate directly to the Zhipu API. ### Impact Assessment An attacker who obtains the key gains the API privileges associated with the victim's Zhipu credential. This can permit unauthorized API requests, consumption of account quota, generation of chargeable usage, and access to any other API operations authorized for that same key. ...[truncated 149 chars]
- Remediation
- ## Remediation Suggestions - Do not pass the Authorization header containing the API key directly in curl's command-line arguments. - Provide sensitive curl configuration through standard input or another protected, non-argument channel supported by the deployed curl version. - Prevent curl from inheriting `ZHIPU_API_KEY` after the header has been prepared when operationally feasible. - Avoid storing the key in a temporary file. If a temporary credential-bearing file is unavoidable, create it with permissions restricted to the owner (`0600`), reject unsafe pre-existing paths, and guarantee deletion with a shell `trap` on normal exit and interruption. - Use a narrowly scoped API key, configure usage limits where supported, and rotate the currently deployed key if process arguments may already have been logged. - Verify the remediation by inspecting the curl process arguments during a test request and confirming that neither the raw key nor the Authorization header is present.
