T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/run_huisheng.sh:174
- Finding
- Bearer Token Exposed Through Process Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `scripts/run_huisheng.sh`, lines 174-188 **Vulnerability Type**: Bearer token disclosure through process arguments **Risk Level**: Medium ### Vulnerable Code ```bash if [[ -n "$body" ]]; then http_status="$( curl -sS -o "$tmp_body" -w '%{http_code}' \ -X "$method" \ -H "Authorization: Bearer $HUISHENG_API_TOKEN" \ -H "Content-Type: application/json" \ --data "$body" \ "$url" )" else http_status="$( curl -sS -o "$tmp_body" -w '%{http_code}' \ -X "$method" \ -H "Authorization: Bearer $HUISHENG_API_TOKEN" \ "$url" )" ``` ### Technical Analysis The script interpolates `HUISHENG_API_TOKEN` directly into a command-line argument passed to `curl`. Consequently, the complete `Authorization` header can appear in curl's process argument vector while the request is running. Depending on operating-system permissions, process isolation, and `/proc` configuration, another local process may be able to inspect this value through mechanisms such as `ps`, process-monitoring tools, or `/proc/<pid>/cmdline`. The risk is especially relevant in shared execution environments where multiple workloads run under the same operating-system account. TLS protects the token while it is transmitted to the API, but it does not prevent local disclosure through process metadata. ### Attack Path 1. A user invokes an authenticated command such as `list-feeds`, `create-feed`, or `delete-episode`. 2. The script launches curl with `Authorization: Bearer <token>` in its argument vector. 3. While curl is running, a concurrent local process with sufficient process-inspection privileges reads its command-line arguments. 4. The process extracts the bearer token from the authorization header. 5. The attacker reuses the token to send requests to `https://huisheng.fm/api`. ### Impact Assessment Successful exploitation exposes the user's personal huisheng.fm API bearer token. The att ...[truncated 420 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions Avoid passing the bearer token as a command-line argument. Supply the sensitive header through a curl configuration delivered over standard input or through another secret-aware mechanism that does not expose it in the process argument vector. For example, construct a temporary curl configuration with restrictive permissions or pass configuration through standard input, while ensuring the token is correctly escaped for curl configuration syntax. The resulting invocation should contain only a non-sensitive option such as `--config -` in its argument vector. Additional hardening measures should include: 1. Ensure diagnostic output never prints the generated authorization configuration. 2. Unset or narrowly scope `HUISHENG_API_TOKEN` when it is no longer required. 3. Run the skill in an isolated user or container context so unrelated workloads cannot inspect its processes. 4. Review execution tracing and debugging settings to ensure shell tracing cannot print the token. 5. Add an automated test that inspects the curl command line during a request and verifies that the token is absent. ]]>
