T09 · Insecure Skill Coding Practices
- Location
scripts/generate.sh:37- Finding
API Key Exposed Through curl Process Arguments
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate.sh, lines 37-40
Vulnerability Type: Sensitive credential exposure through command-line arguments
Risk Level: Mediumbash # 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
$KEYbefore launchingcurl, placing the complete bearer token inside theAuthorizationheader 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.mdacknowledges this process-list visibility, but documentation does not mitigate the underlying credential exposure.Attack Path
- A victim exports a valid
ZHIPU_API_KEYand runsscripts/generate.sh. - The script expands
$KEYinto thecurlcommand-line argument containing the Authorization header. - During the API request, a local user or monitoring service with sufficient process-inspection access reads or records the curl argument list.
- The observer extracts the bearer token from the captured header.
- 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]
- A victim exports a valid
- Remediation
View 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_KEYafter 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 shelltrapon 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.
