T09 · Insecure Skill Coding Practices
Warning
- Location
- bitbucket-cli.sh:22
- Finding
- Bitbucket API Token Exposed Through Process Arguments<![CDATA[ ## Vulnerability Details **File Location**: `bitbucket-cli.sh`, lines 22–45 **Vulnerability Type**: Credential exposure through command-line arguments **Risk Level**: Medium ### Vulnerable Code ```bash AUTH="$ATLASSIAN_EMAIL:$BITBUCKET_API_TOKEN" BASE="https://api.bitbucket.org/2.0" WS="$BITBUCKET_WORKSPACE" # --- HTTP helpers --- bb_get() { local response http_code body response=$(curl -s -w "\n%{http_code}" -u "$AUTH" -H "Accept: application/json" "$1") http_code=$(echo "$response" | tail -1) body=$(echo "$response" | sed '$d') if [ "$http_code" -ge 400 ]; then local err="{\"error\": \"HTTP $http_code\", \"url\": \"$1\"}" echo "$err" >&2 echo "$err" exit 1 fi echo "$body" } bb_get_raw() { local http_code body body=$(curl -s -w "\n%{http_code}" -u "$AUTH" "$1") ``` ### Technical Analysis The script concatenates the Atlassian email address and Bitbucket API token into `AUTH`, then supplies the resulting credential to `curl` using the `-u` command-line option. Consequently, the credential may appear in the process argument vector while `curl` is running. On systems where process arguments are visible to other users, privileged monitoring agents, diagnostic tooling, or command telemetry, an observer may recover the complete Basic Authentication credential. Shell quoting prevents argument splitting but does not prevent exposure through process inspection. The documented recommendation to use a read-only token limits the possible damage, but it does not eliminate credential disclosure. The actual scope depends on the permissions assigned to the exposed token. ### Attack Path 1. An attacker obtains local process-inspection capability or access to telemetry that records process command lines. 2. A user invokes any CLI operation that calls `bb_get` or `bb_get_raw`. 3. The script launches `curl` with `-u "$ATLASSIAN_EMAIL:$BITBUCKET_API_TOKEN"`. 4. The attacker observes the `curl` pr ...[truncated 781 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Do not pass credentials through command-line arguments. - Prefer a protected credential mechanism such as a temporary curl configuration supplied through standard input or a securely permissioned credential file. Ensure any temporary credential material is created with mode `0600` and removed reliably. - Where platform support permits, provide the authorization value through a protected file descriptor rather than the process argument vector. - Prevent verbose tracing and command telemetry from recording authentication material. - Run the skill in an isolated execution environment where unrelated users cannot inspect its processes. - Continue requiring a separate, narrowly scoped Bitbucket token with only `Repositories: Read` and `Pull requests: Read`. - Rotate the token if process arguments may previously have been recorded or exposed. ]]>
