T09 · Insecure Skill Coding Practices
Warning
- Location
- SKILL.md:25
- Finding
- Bearer Token Exposed Through Command-Line Arguments## Vulnerability Details **File Location**: `SKILL.md`, lines 25–29; repeated at lines 43–47 and 70–74 **Vulnerability Type**: Bearer token exposure through process arguments **Risk Level**: Medium ### Vulnerable Code ```bash curl -s --location --request POST 'https://api.coze.com/v1/workflow/stream_run' \ --header "Authorization: Bearer $COZE_PAT_KEY" \ --header 'Content-Type: application/json' \ --data-raw '{ ``` ### Technical Analysis The shell expands `$COZE_PAT_KEY` before starting `curl`, placing the complete authorization header in the process argument vector. While the request is transmitted over HTTPS, local process-inspection interfaces, diagnostic utilities, monitoring agents, audit systems, or process telemetry may capture the expanded command line while the request is running. The same insecure authorization pattern appears in all three documented `curl` examples. The file does not hardcode an actual credential, but its recommended invocation method can expose a user-supplied PAT to local observers or logs. ### Attack Path 1. A user exports a valid Coze PAT as `COZE_PAT_KEY`. 2. The user runs one of the documented `curl` commands. 3. The shell expands the variable into `Authorization: Bearer <token>` in the `curl` argument vector. 4. A local user, privileged monitoring process, or command-line telemetry system observes or records the process arguments. 5. The observer extracts the PAT and submits authenticated requests to the Coze API. 6. The stolen token remains usable until it expires or is revoked. Exploitation depends on the operating system's process-visibility controls and the attacker's local access or access to collected process telemetry. ### Impact Assessment A stolen PAT grants the attacker the permissions assigned to that token. This may permit unauthorized workflow execution, access to workflow-generated data, consumption of account quotas, and actions available through ...[truncated 176 chars]
- Remediation
- ## Remediation Suggestions - Avoid passing bearer tokens directly in command-line arguments. - Use a client or wrapper that constructs the authorization header in memory rather than in the process argument vector. - If `curl` must be used, place sensitive options in a temporary configuration file created with restrictive permissions: ```bash umask 077 config_file="$(mktemp)" trap 'rm -f "$config_file"' EXIT printf '%s\n' \ 'header = "Content-Type: application/json"' \ "header = \"Authorization: Bearer ${COZE_PAT_KEY}\"" \ > "$config_file" curl --silent --show-error \ --location \ --request POST \ --config "$config_file" \ --max-time 120 \ --data-raw '{ "workflow_id": "your_workflow_id", "parameters": { "key": "value" } }' \ 'https://api.coze.com/v1/workflow/stream_run' ``` - Ensure the temporary configuration file is deleted on normal exit and interruption. - Prevent shell tracing around secret-bearing operations and configure monitoring systems to redact authorization headers. - Use narrowly scoped, short-lived PATs where supported. - Revoke and rotate any token suspected of having been exposed.
