Text of codeql.github.com › codeql-query-help › actions › actions-excessive-secrets-exposure as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

Excessive Secrets Exposure — CodeQL query help documentation

CodeQL query help documentation » CodeQL query help for GitHub Actions » Excessive Secrets Exposure ¶ ID: actions/excessive-secrets-exposure Kind: problem Security severity: 5.0 Severity: warning Precision: high Tags: - actions - security - external/cwe/cwe-312 Query suites: - actions-code-scanning.qls - actions-security-extended.qls - actions-security-and-quality.qls Click to see the query in the CodeQL repository Overview ¶ When the workflow runner cannot determine what secrets are needed to run the workflow, it will pass all the available secrets to the runner including organization and repository secrets.

This violates the least privileged principle and increases the impact of a potential vulnerability affecting the workflow. Recommendation ¶ Only pass those secrets that are needed by the workflow. Avoid using expressions such as toJSON(secrets) or dynamically accessed secrets such as secrets[format('GH_PAT_%s', matrix.env)] since the workflow will need to receive all secrets to decide at runtime which one needs to be used.

Example ¶ Incorrect Usage ¶ env : ALL_SECRETS : ${{ toJSON(secrets) }} strategy : matrix : env : [ PROD , DEV ] env : GH_TOKEN : ${{ secrets[format('GH_PAT_%s', matrix.env)] }} Correct Usage ¶ env : NEEDED_SECRET : ${{ secrets.GH_PAT }} strategy : matrix : env : [ PROD , DEV ] --- if : matrix.env == "PROD" env : GH_TOKEN : ${{ secrets.GH_PAT_PROD }} --- if : matrix.env == "DEV" env : GH_TOKEN : ${{ secrets.GH_PAT_DEV }} References ¶ GitHub Docs: Using secrets in GitHub Actions . poutine: Job uses all secrets . © GitHub, Inc.

Terms Privacy