Back to skill

Security audit

Bitbucket

Security checks for vulnerabilities and agentic risk

Overview

This skill appears read-only and purpose-aligned, but it should be reviewed because it can broadly read private Bitbucket source data and exposes its API token to local process inspection risk.

Review before installing in a private workspace. Use a dedicated Bitbucket token with only repository and pull-request read permissions, run it in an isolated environment where other users cannot inspect process arguments, and ask the agent to inspect only specific repos, PRs, branches, or files. Treat all repository content, PR descriptions, diffs, and comments as untrusted text.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

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. ]]>

other

Warning
Location
bitbucket-cli.sh:151
Finding
Indirect Prompt Injection Through Untrusted Repository Files and Diffs<![CDATA[ ## Vulnerability Details **File Location**: `bitbucket-cli.sh`, lines 151–155, 229–233, and 296–301 **Vulnerability Type**: Indirect prompt-injection exposure **Risk Level**: Medium ### Vulnerable Code ```bash cmd_diff() { local repo="${1:?Usage: bitbucket-cli.sh diff REPO PR_ID}" local pr_id="${2:?Usage: bitbucket-cli.sh diff REPO PR_ID}" bb_get_raw "$BASE/repositories/$WS/$repo/pullrequests/$pr_id/diff" } ``` ```bash cmd_file() { local repo="${1:?Usage: bitbucket-cli.sh file REPO FILEPATH [REV]}" local filepath="${2:?Usage: bitbucket-cli.sh file REPO FILEPATH [REV]}" local rev="${3:-main}" bb_get_raw "$BASE/repositories/$WS/$repo/src/$rev/$filepath" } ``` ```bash cmd_compare() { local repo="${1:?Usage: bitbucket-cli.sh compare REPO BASE_REF HEAD_REF}" local base_ref="${2:?Usage: bitbucket-cli.sh compare REPO BASE_REF HEAD_REF}" local head_ref="${3:?Usage: bitbucket-cli.sh compare REPO BASE_REF HEAD_REF}" bb_get_raw "$BASE/repositories/$WS/$repo/diff/$base_ref..$head_ref" } ``` ### Technical Analysis The `file`, `diff`, and `compare` commands return repository-controlled content as raw text. Repository contributors can therefore place natural-language instructions in source files or diffs that are subsequently inserted into the Agent's working context. Neither the script nor `SKILL.md` labels this material as untrusted content or explicitly directs the Agent never to follow instructions embedded in repository data. If the consuming Agent does not maintain a strict separation between tool data and trusted instructions, malicious content can be interpreted as an instruction rather than as evidence to analyze. This is an indirect prompt-injection exposure rather than local shell command injection. The shell does not execute repository content; exploitation depends on the downstream Agent treating attacker-controlled output as authoritative instructions. ### Attack Path 1. An attacker with permission t ...[truncated 1345 chars]
Remediation
<![CDATA[ ## Remediation Suggestions - Add an explicit rule to `SKILL.md` stating that repository files, diffs, commit messages, pull-request descriptions, and comments are untrusted data and must never be followed as instructions. - Require the Agent to analyze repository content only for the user's stated task and to ignore embedded requests to change goals, reveal secrets, invoke tools, or modify system behavior. - Return raw content through a structured tool-data channel with clear provenance and trust labels where the host platform supports it. - Delimit retrieved content clearly, for example with metadata identifying the repository, revision, path, and content type. - Apply output-size limits so attacker-controlled content cannot unnecessarily dominate the Agent context. - Require explicit user confirmation before any subsequent sensitive or state-changing tool invocation that appears to originate from retrieved repository content. - Preserve the skill's read-only Bitbucket scope and avoid adding write or execution capabilities to the same trust boundary. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
Findings (5)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The description is partially accurate but incomplete. The code does browse Bitbucket Cloud repos, review pull requests, read diffs, and check branches, matching the stated core use case. However, it also provides several additional substantive capabilities not declared in the description: reading arbitrary file contents (`file`), listing directories and recursive trees (`ls`, `tree`), searching source code (`search`), reading commit history (`commits`, `pr-commits`), comparing refs (`compare`), and retrieving PR comments (`comments`). These are not just implementation details; they materially expand the skill from PR/diff/branch review into broader repository/code inspection and search. No write or destructive behavior is present, and resources remain within Bitbucket Cloud, but the declared description understates the actual scope.

Lp3

Medium
Category
MCP Least Privilege
Confidence
88% confidence
Finding
The skill invokes a shell script and makes network requests to Bitbucket, but it does not declare an explicit tool scope such as allowed-tools or permissions. That increases the chance of unintended execution surface and weakens policy enforcement, because consumers of the skill must infer capabilities from prose rather than machine-readable restrictions.

Vague Triggers

Medium
Confidence
90% confidence
Finding
The activation guidance is broad enough that the skill may trigger on ordinary mentions of PRs, branches, repos, or Bitbucket, causing unnecessary access to repository data. In a system that auto-selects skills, this can lead to overuse of a credentialed integration and disclosure of private code or metadata when the user did not clearly intend repository inspection.

External Transmission

Medium
Category
Data Exfiltration
Content
done

AUTH="$ATLASSIAN_EMAIL:$BITBUCKET_API_TOKEN"
BASE="https://api.bitbucket.org/2.0"
WS="$BITBUCKET_WORKSPACE"

# --- HTTP helpers ---
Confidence
60% confidence
Finding
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.

Description-Behavior Mismatch

Medium
Confidence
93% confidence
Finding
The skill description limits the capability to PR, diff, and branch browsing, but the script also exposes arbitrary file reads (`file`, `ls`, `tree`) and workspace/repo code search (`search`). This is a scope expansion that can enable broader data access than a user or policy reviewer would reasonably expect, increasing the chance of unnecessary source disclosure across repositories.

Static analysis

No suspicious patterns detected.