Skip to content

Maintenance: Avoid Expaning Secrets in a run block in a workflow #4369

@sdangol

Description

@sdangol

Summary

As per some SonarQube findings, we should pass secrets to steps through environment variables instead of command-line arguments.

The following files are flagged with the finding:

  • .github/workflows/bootstrap_region.yml
  • .github/workflows/dispatch_analytics.yml
  • .github/workflows/layer_balance.yml
  • .github/workflows/publish-package.yml

Why is this needed?

GitHub Actions workflows should handle secrets securely by passing them through environment variables rather than directly expanding them in run commands. When secrets are expanded directly in run commands using GitHub’s expression syntax (${{ secrets.SECRET_NAME }}), they may be exposed in process lists, shell history, or files.

This practice increases the risk of accidental secret exposure, as command-line arguments and process information can be visible to other processes running on the same system.

Which area does this relate to?

Automation

Solution

name: Example

on:
  pull_request:

jobs:
  main:
    steps:
      - name: example
        env:
          SECRET: ${{ secrets.EXAMPLE_SECRET }}
        run: |
          example-command "$SECRET"

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

Metadata

Metadata

Assignees

Labels

automationThis item relates to automationcompletedThis item is complete and has been merged/shippedinternalPRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.)

Type

No type

Projects

Status

Shipped

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions