# GHSA-4jhj-3gv3-c3gr: CLI for Vela Insecure Variable Substitution

> Attackers can expose secrets in Vela pipelines by injecting them into insensitive fields, bypassing log masking and 'no commands' restrictions.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 15 Mar 2024
- **Also known as:** GO-2024-2647

## What is GHSA-4jhj-3gv3-c3gr?

GHSA-4jhj-3gv3-c3gr is a vulnerability in github.com/go-vela/cli, published on 15 Mar 2024. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

### Impact
Vela pipelines can use variable substitution combined with insensitive fields like `parameters`, `image` and `entrypoint` to inject secrets into a plugin/image and — by using common substitution string manipulation — can bypass log masking and expose secrets without the use of the commands block. This unexpected behavior primarily impacts secrets restricted by the "no commands" option. This can lead to unintended use of the secret value, and increased risk of exposing the secret during image execution bypassing log masking.

Given by the following substitution examples:
using `parameters`
```yaml
steps:
  - name: example
    image: <some plugin>
    secrets: [ example_secret ]
    parameters:
      example: $${EXAMPLE_SECRET}
```

using `image` tag
```yaml
steps:
  - name: example
    image: <some plugin>:latest${EXAMPLE_SECRET}
    secrets: [ example_secret ]
```

using `entrypoint` as a shim for `commands`
```yaml
steps:
  - name: example
    image: <some plugin>
    secrets: [ example_secret ]
    entrypoint:
      [
        "sh",
        "-c",
        "echo $EXAMPLE_SECRET",
      ]
```

**To exploit this** the pipeline author must be supplying the secrets to a plugin that is designed in such a way that will print those parameters in logs. Plugin parameters are not designed for sensitive values and are often intentionally printed throughout execution for informational/debugging purposes. Parameters should therefore be treated as insensitive.

While Vela provides secrets masking, secrets exposure is not entirely solved by the masking process. A docker image (plugin) can easily expose secrets if they are not handled properly, or altered in some way. There is a responsibility on the end-user to understand how values injected into a plugin are used. This is a risk that exists for many CICD systems (like GitHub Actions) that handle sensitive runtime variables. Rather, the greater risk is that users who restrict a secret to the "no commands" option and use image restriction can still have their secret value exposed via substitution tinkering, which turns the image and command restrictions into a false sense of security.

### Patches
N/A

### Workarounds
- Do not provide sensitive values to plugins that can potentially expose them, especially in `parameters` that are not intended to be used for sensitive values.
- Ensure plugins (especially those that utilize shared secrets) follow best practices to avoid logging parameters that are expected to be sensitive.
- Minimize secrets with `pull_request` events enabled, as this allows users to change pipeline configurations and pull in secrets to steps not typically part of the CI process.
- Make use of the build approval setting, restricting builds from untrusted users
- Limit use of shared secrets, as they are less restrictive to access by nature.

### References
- https://github.com/go-vela/worker

### For more information

If you have any questions or comments about this advisory:

- Email us at [vela@target.com](mailto:vela@target.com)

Affected products: `go-vela/worker`

## Which versions are affected by GHSA-4jhj-3gv3-c3gr?

3 open source packages ship an affected version, including github.com/go-vela/cli.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/go-vela/cli` | Go | All versions | 0.23.2 |
| `github.com/go-vela/cli` | Go | All versions | 0.23.2 |
| `github.com/go-vela/cli` | Go | All versions | 0.23.2 |

## How do I fix GHSA-4jhj-3gv3-c3gr?

Upgrade github.com/go-vela/cli to 0.23.2 or later.

## Is GHSA-4jhj-3gv3-c3gr being exploited?

There is no known exploitation of GHSA-4jhj-3gv3-c3gr in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-4jhj-3gv3-c3gr and fix it if it is affected.

What it is: GHSA-4jhj-3gv3-c3gr is a vulnerability in github.com/go-vela/cli, published on 15 Mar 2024. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-4jhj-3gv3-c3gr in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/go-vela/cli (Go): affected all versions; fixed in 0.23.2
- github.com/go-vela/cli (Go): affected all versions; fixed in 0.23.2
- github.com/go-vela/cli (Go): affected all versions; fixed in 0.23.2

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-4jhj-3gv3-c3gr/ (Markdown: https://insights.sbomify.com/GHSA-4jhj-3gv3-c3gr/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-4jhj-3gv3-c3gr

---
From sbomify Insights: https://insights.sbomify.com/GHSA-4jhj-3gv3-c3gr/
Summaries are generated and may contain mistakes; the official description above is the record.
