Skip to content

Maintenance: Pass only the required secret to workflow #4363

@sdangol

Description

@sdangol

Summary

Provide reusable workflows with access only to the specific secrets they require and use individual secret references instead of inheriting all secrets. This was alerted by a SonarQube finding

In file .github/workflows/rebuild_latest_docs.yml

jobs:
  release-docs:
    permissions:
      id-token: write  # trade JWT token for AWS credentials in AWS Docs account
      contents: read  # read from this repo to publish docs
    secrets : inherit <--- Use only required secrets instead of inherit

Similarly, secrets are being inherited in these files

Why is this needed?

GitHub Actions workflows should follow the principle of least privilege by providing reusable workflows with access only to the specific secrets they require. When secrets: inherit is used to call a reusable workflow, all repository secrets become available to the reusable workflow, creating unnecessary security risks.

This practice increases the attack surface and potential for secret exposure, as any vulnerability in the reusable workflow could compromise all secrets rather than just the ones actually needed. Additionally, it violates the principle of least privilege by granting broader access than necessary.

Which area does this relate to?

Automation

Solution

jobs:
  release-docs:
    permissions:
      id-token: write  # trade JWT token for AWS credentials in AWS Docs account
      contents: read  # read from this repo to publish docs
    secrets:
      AWS_DOCS_ROLE_ARN: ${{ secrets.AWS_DOCS_ROLE_ARN }}
      AWS_DOCS_BUCKET: ${{ secrets.AWS_DOCS_BUCKET }}

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