From 81db9f345a5955747bfae8f12192b25a6e9b7099 Mon Sep 17 00:00:00 2001 From: wrslatz Date: Tue, 29 Apr 2025 12:15:23 -0400 Subject: [PATCH 01/10] docs: untrusted code risks in actions --- .../actions/reference/security/secure-use.md | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/content/actions/reference/security/secure-use.md b/content/actions/reference/security/secure-use.md index 8876f100de3e..7716aa2127ef 100644 --- a/content/actions/reference/security/secure-use.md +++ b/content/actions/reference/security/secure-use.md @@ -105,7 +105,53 @@ For more information, see [AUTOTITLE](/code-security/code-scanning/introduction- To help mitigate the risk of an exposed token, consider restricting the assigned permissions. For more information, see [AUTOTITLE](/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token). -### Using third-party actions +{% ifversion custom-org-roles %} + +## Understanding the risks of untrusted code checkout + +Similar to script injection attacks, untrusted pull request content that automatically triggers Actions processing can also pose a security risk. The `pull_request_target` and `workflow_run` workflow triggers, when used with the checkout of an untrusted pull request, expose the repository to security compromises. These workflows have write access and access to secrets in the target repository, which can be exploited to take over a repository. + +Review the [`pull_request_target` trigger documentation](/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target) and the [`workflow_run` trigger documentation](/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflow-run) for more information on these triggers, how to use them, and the risks associated with them. + +For additional explanation, examples, and guidance on the risks of untrusted code checkout, see [Keeping your GitHub Actions and workflows secure: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/) from GitHub Security Lab and the [Dangerous Workflow check documentation](https://github.com/ossf/scorecard/blob/main/docs/checks.md#dangerous-workflow) from OpenSSF Scorecard. + +## Good practices for mitigating untrusted code checkout risks + +There are a number of different approaches available to help you mitigate the risk of untrusted code checkout in Actions workflows: + +### Avoid potentially dangerous workflow triggers + +Avoid using the `pull_request_target` and `workflow_run` workflow triggers if not necessary. Only use these workflow triggers when the workflow actually needs the privileged context and access from the target repo to be available in the workflow. + +### Do not use the `pull_request_target` and `workflow_run` workflow triggers with untrusted content + +Avoid using the `pull_request_target` and `workflow_run` workflow triggers with untrusted pull requests or code content. Workflows that use these triggers must not explicitly checkout untrusted code, including from pull request forks or from repositories that are not under your control. + +### Use CodeQL to detect potentially vulnerable workflows + +[CodeQL](/code-security/code-scanning/introduction-to-code-scanning/about-code-scanning-with-codeql) can scan and detect potentially vulnerable GitHub Actions workflows. [Configure the default setup for CodeQL](/code-security/code-scanning/enabling-code-scanning/configuring-default-setup-for-code-scanning) for the repository and ensure that GitHub Actions scanning is enabled. + +### Use OpenSSF Scorecards to detect potentially vulnerable workflows + +[OpenSSF Scorecards](#use-openssf-scorecards-to-detect-potentially-vulnerable-workflows) can help you identify potentially vulnerable workflows, along with other security risks when using GitHub Actions. + +## Managing permissions for {% data variables.product.prodname_actions %} settings in your organization + +You can practice the principle of least privilege for your organization's CI/CD pipeline with {% data variables.product.prodname_actions %} by administering custom organization roles. A custom organization role is a way to grant an individual or team in your organization the ability to control certain subsets of settings without granting full administrative control of the organization and its repositories. + +{% data reusables.actions.org-roles-for-gh-actions %} + +For more information, see [AUTOTITLE](/organizations/managing-peoples-access-to-your-organization-with-roles/about-custom-organization-roles). + +{% endif %} + +## Using OpenID Connect to access cloud resources + +{% data reusables.actions.about-oidc-short-overview %} + +{% data reusables.actions.oidc-custom-claims-aws-restriction %} + +## Using third-party actions The individual jobs in a workflow can interact with (and compromise) other jobs. For example, a job querying the environment variables used by a later job, writing files to a shared directory that a later job processes, or even more directly by interacting with the Docker socket and inspecting other running containers and executing commands in them. From e4df5a1c63c3449368afee569bd7c065a5c5720c Mon Sep 17 00:00:00 2001 From: wrslatz Date: Tue, 29 Apr 2025 12:17:05 -0400 Subject: [PATCH 02/10] docs: expand pull_request_target warning links --- .../actions/pull-request-target-permissions-warning.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/reusables/actions/pull-request-target-permissions-warning.md b/data/reusables/actions/pull-request-target-permissions-warning.md index 019b53f520eb..69ca2c1dcbe1 100644 --- a/data/reusables/actions/pull-request-target-permissions-warning.md +++ b/data/reusables/actions/pull-request-target-permissions-warning.md @@ -1,2 +1,2 @@ > [!WARNING] -> For workflows that are triggered by the `pull_request_target` event, the `GITHUB_TOKEN` is granted read/write repository permission unless the `permissions` key is specified and the workflow can access secrets, even when it is triggered from a fork. Although the workflow runs in the context of the base of the pull request, you should make sure that you do not check out, build, or run untrusted code from the pull request with this event. Additionally, any caches share the same scope as the base branch. To help prevent cache poisoning, you should not save the cache if there is a possibility that the cache contents were altered. For more information, see [Keeping your GitHub Actions and workflows secure: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests) on the GitHub Security Lab website. +> For workflows that are triggered by the `pull_request_target` event, the `GITHUB_TOKEN` is granted read/write repository permission unless the `permissions` key is specified and the workflow can access secrets, even when it is triggered from a fork. Although the workflow runs in the context of the base of the pull request, you should make sure that you do not check out, build, or run untrusted code from the pull request with this event. Additionally, any caches share the same scope as the base branch. To help prevent cache poisoning, you should not save the cache if there is a possibility that the cache contents were altered. For more information, see [Understanding the risks of untrusted code checkout](/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#understanding-the-risks-of-untrusted-code-checkout) in the Security Hardening for GitHub Actions documentation and [Keeping your GitHub Actions and workflows secure: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests) on the GitHub Security Lab website. From bccd3760bc3e707d69ae48026223b466163fed9a Mon Sep 17 00:00:00 2001 From: wrslatz Date: Tue, 29 Apr 2025 12:18:33 -0400 Subject: [PATCH 03/10] docs: warning for workflow_run security risks --- .../workflows-and-actions/events-that-trigger-workflows.md | 2 ++ data/reusables/actions/workflow-run-permissions-warning.md | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 data/reusables/actions/workflow-run-permissions-warning.md diff --git a/content/actions/reference/workflows-and-actions/events-that-trigger-workflows.md b/content/actions/reference/workflows-and-actions/events-that-trigger-workflows.md index 8c4fe351820b..2edad4d26814 100644 --- a/content/actions/reference/workflows-and-actions/events-that-trigger-workflows.md +++ b/content/actions/reference/workflows-and-actions/events-that-trigger-workflows.md @@ -1222,6 +1222,8 @@ For more information, see the {% data variables.product.prodname_cli %} informat This event occurs when a workflow run is requested or completed. It allows you to execute a workflow based on execution or completion of another workflow. The workflow started by the `workflow_run` event is able to access secrets and write tokens, even if the previous workflow was not. This is useful in cases where the previous workflow is intentionally not privileged, but you need to take a privileged action in a later workflow. +{% data reusables.actions.workflow-run-permissions-warning %} + In this example, a workflow is configured to run after the separate "Run Tests" workflow completes. ```yaml diff --git a/data/reusables/actions/workflow-run-permissions-warning.md b/data/reusables/actions/workflow-run-permissions-warning.md new file mode 100644 index 000000000000..23d9aad1d0ac --- /dev/null +++ b/data/reusables/actions/workflow-run-permissions-warning.md @@ -0,0 +1,2 @@ +> [!WARNING] +> For workflows that are triggered by the `workflow_run` event, the `GITHUB_TOKEN` is granted read/write repository permission unless the `permissions` key is specified and the workflow can access secrets, even when it is triggered from a fork. You should make sure that you do not check out, build, or run untrusted code from the pull request or other untrusted sources with this event. Additionally, any caches share the same scope as the base branch. To help prevent cache poisoning, you should not save the cache if there is a possibility that the cache contents were altered. For more information, see [Understanding the risks of untrusted code checkout](/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#understanding-the-risks-of-untrusted-code-checkout) in the Security Hardening for GitHub Actions documentation and [Keeping your GitHub Actions and workflows secure: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests) on the GitHub Security Lab website. From e6a50fb5ba48994195e10f794a662b6f292ea307 Mon Sep 17 00:00:00 2001 From: Sharra-writes Date: Wed, 9 Jul 2025 17:23:45 -0700 Subject: [PATCH 04/10] Update content/actions/how-tos/security-for-github-actions/security-guides/security-hardening-for-github-actions.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jaroslav Lobačevski Co-authored-by: Will Slattum --- content/actions/reference/security/secure-use.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/actions/reference/security/secure-use.md b/content/actions/reference/security/secure-use.md index 7716aa2127ef..3933bba691e5 100644 --- a/content/actions/reference/security/secure-use.md +++ b/content/actions/reference/security/secure-use.md @@ -125,7 +125,7 @@ Avoid using the `pull_request_target` and `workflow_run` workflow triggers if no ### Do not use the `pull_request_target` and `workflow_run` workflow triggers with untrusted content -Avoid using the `pull_request_target` and `workflow_run` workflow triggers with untrusted pull requests or code content. Workflows that use these triggers must not explicitly checkout untrusted code, including from pull request forks or from repositories that are not under your control. +Avoid using the `pull_request_target` and `workflow_run` workflow triggers with untrusted pull requests or code content. Workflows that use these triggers must not explicitly checkout untrusted code, including from pull request forks or from repositories that are not under your control. Workflows triggered on `workflow_run` should treat artifacts uploaded from other workflows with caution (i.e. as untrusted). ### Use CodeQL to detect potentially vulnerable workflows From 834a87794fca9edb8b494ffae49cfa3e43615e1b Mon Sep 17 00:00:00 2001 From: Sharra-writes Date: Wed, 9 Jul 2025 17:24:49 -0700 Subject: [PATCH 05/10] Update content/actions/how-tos/security-for-github-actions/security-guides/security-hardening-for-github-actions.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jaroslav Lobačevski Co-authored-by: Will Slattum --- content/actions/reference/security/secure-use.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/actions/reference/security/secure-use.md b/content/actions/reference/security/secure-use.md index 3933bba691e5..88fc5b569db4 100644 --- a/content/actions/reference/security/secure-use.md +++ b/content/actions/reference/security/secure-use.md @@ -109,7 +109,7 @@ To help mitigate the risk of an exposed token, consider restricting the assigned ## Understanding the risks of untrusted code checkout -Similar to script injection attacks, untrusted pull request content that automatically triggers Actions processing can also pose a security risk. The `pull_request_target` and `workflow_run` workflow triggers, when used with the checkout of an untrusted pull request, expose the repository to security compromises. These workflows have write access and access to secrets in the target repository, which can be exploited to take over a repository. +Similar to script injection attacks, untrusted pull request content that automatically triggers Actions processing can also pose a security risk. The `pull_request_target` and `workflow_run` workflow triggers, when used with the checkout of an untrusted pull request, expose the repository to security compromises. These workflows are privileged (i.e. they share the same cache of the main branch with other privileged workflow triggers, may have repository write access and access to referenced secrets), which can be exploited to take over a repository. Review the [`pull_request_target` trigger documentation](/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target) and the [`workflow_run` trigger documentation](/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflow-run) for more information on these triggers, how to use them, and the risks associated with them. From 809c2c594fb752cf199e5dbd0ccd28f4125880b6 Mon Sep 17 00:00:00 2001 From: Sharra-writes Date: Wed, 9 Jul 2025 17:25:00 -0700 Subject: [PATCH 06/10] Update content/actions/how-tos/security-for-github-actions/security-guides/security-hardening-for-github-actions.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jaroslav Lobačevski Co-authored-by: Will Slattum --- content/actions/reference/security/secure-use.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/actions/reference/security/secure-use.md b/content/actions/reference/security/secure-use.md index 88fc5b569db4..2c8edcc7e7c8 100644 --- a/content/actions/reference/security/secure-use.md +++ b/content/actions/reference/security/secure-use.md @@ -121,7 +121,7 @@ There are a number of different approaches available to help you mitigate the ri ### Avoid potentially dangerous workflow triggers -Avoid using the `pull_request_target` and `workflow_run` workflow triggers if not necessary. Only use these workflow triggers when the workflow actually needs the privileged context and access from the target repo to be available in the workflow. +Avoid using the `pull_request_target` workflow trigger if not necessary. Prefer using `workflow_run` for privilege separation between workflows as described in [Keeping your GitHub Actions and workflows secure: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests). Only use these workflow triggers when the workflow actually needs the privileged context. ### Do not use the `pull_request_target` and `workflow_run` workflow triggers with untrusted content From d03bd88ce97c7a85013428739215f39885824f84 Mon Sep 17 00:00:00 2001 From: Sharra-writes Date: Wed, 9 Jul 2025 17:25:11 -0700 Subject: [PATCH 07/10] Update data/reusables/actions/pull-request-target-permissions-warning.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jaroslav Lobačevski Co-authored-by: Will Slattum --- .../actions/pull-request-target-permissions-warning.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/reusables/actions/pull-request-target-permissions-warning.md b/data/reusables/actions/pull-request-target-permissions-warning.md index 69ca2c1dcbe1..c93fce14d35e 100644 --- a/data/reusables/actions/pull-request-target-permissions-warning.md +++ b/data/reusables/actions/pull-request-target-permissions-warning.md @@ -1,2 +1,2 @@ > [!WARNING] -> For workflows that are triggered by the `pull_request_target` event, the `GITHUB_TOKEN` is granted read/write repository permission unless the `permissions` key is specified and the workflow can access secrets, even when it is triggered from a fork. Although the workflow runs in the context of the base of the pull request, you should make sure that you do not check out, build, or run untrusted code from the pull request with this event. Additionally, any caches share the same scope as the base branch. To help prevent cache poisoning, you should not save the cache if there is a possibility that the cache contents were altered. For more information, see [Understanding the risks of untrusted code checkout](/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#understanding-the-risks-of-untrusted-code-checkout) in the Security Hardening for GitHub Actions documentation and [Keeping your GitHub Actions and workflows secure: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests) on the GitHub Security Lab website. +> For workflows that are triggered by the `pull_request_target` event, the `GITHUB_TOKEN` may be granted read/write repository permission (unless the `permissions` key is explicitly specified in the workflow or repository/organization default permission are set to Read-Only) and the workflow can access referenced secrets, even when it is triggered from a fork. Although the workflow runs in the context of the base of the pull request, you should be cautious if checking out untrusted code from the pull request with this event. Make sure that you do not build, or run untrusted code from the pull request. When `pull_request_target` is triggered against the main branch it shares the same cache as the other privileged workflows running in the context of the main branch. Running untrusted code on this trigger may lead to to cache poisoning. For more information, see [Understanding the risks of untrusted code checkout](/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#understanding-the-risks-of-untrusted-code-checkout) in the Security Hardening for GitHub Actions documentation and [Keeping your GitHub Actions and workflows secure: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests) on the GitHub Security Lab website. From b1ff7f626772c861a5276d7bd5cf382d11a569d6 Mon Sep 17 00:00:00 2001 From: Sharra-writes Date: Wed, 9 Jul 2025 17:25:23 -0700 Subject: [PATCH 08/10] Update data/reusables/actions/workflow-run-permissions-warning.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jaroslav Lobačevski Co-authored-by: Will Slattum --- data/reusables/actions/workflow-run-permissions-warning.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/reusables/actions/workflow-run-permissions-warning.md b/data/reusables/actions/workflow-run-permissions-warning.md index 23d9aad1d0ac..7ecbac9e71e0 100644 --- a/data/reusables/actions/workflow-run-permissions-warning.md +++ b/data/reusables/actions/workflow-run-permissions-warning.md @@ -1,2 +1,2 @@ > [!WARNING] -> For workflows that are triggered by the `workflow_run` event, the `GITHUB_TOKEN` is granted read/write repository permission unless the `permissions` key is specified and the workflow can access secrets, even when it is triggered from a fork. You should make sure that you do not check out, build, or run untrusted code from the pull request or other untrusted sources with this event. Additionally, any caches share the same scope as the base branch. To help prevent cache poisoning, you should not save the cache if there is a possibility that the cache contents were altered. For more information, see [Understanding the risks of untrusted code checkout](/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#understanding-the-risks-of-untrusted-code-checkout) in the Security Hardening for GitHub Actions documentation and [Keeping your GitHub Actions and workflows secure: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests) on the GitHub Security Lab website. +> Workflows triggered by the `workflow_run` event are privileged (i.e. they share the same cache of the main branch with other privileged workflow triggers, may have repository write access and access to referenced secrets). You should make sure that you do not check out, build, or run untrusted code from the pull request or other untrusted sources with this event. The workflow shares the same cache as the other privileged workflows running in the context of the main branch. Running untrusted code on this trigger may lead to to cache poisoning. For more information, see [Understanding the risks of untrusted code checkout](/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#understanding-the-risks-of-untrusted-code-checkout) in the Security Hardening for GitHub Actions documentation and [Keeping your GitHub Actions and workflows secure: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests) on the GitHub Security Lab website. From 1871bfa04f5a004614d50d87f53f10040c5365a3 Mon Sep 17 00:00:00 2001 From: wrslatz Date: Wed, 9 Jul 2025 21:15:48 -0400 Subject: [PATCH 09/10] docs: sync hardening info to enterprise-onboarding --- .../security-hardening-for-github-actions.md | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/content/enterprise-onboarding/github-actions-for-your-enterprise/security-hardening-for-github-actions.md b/content/enterprise-onboarding/github-actions-for-your-enterprise/security-hardening-for-github-actions.md index bdb0a82a9c9e..375c71728d29 100644 --- a/content/enterprise-onboarding/github-actions-for-your-enterprise/security-hardening-for-github-actions.md +++ b/content/enterprise-onboarding/github-actions-for-your-enterprise/security-hardening-for-github-actions.md @@ -139,7 +139,7 @@ In this example, the attempted script injection is unsuccessful, which is reflec PR title did not start with 'octocat' ``` -With this approach, the value of the {% raw %}`${{ github.event.issue.title }}`{% endraw %} expression is stored in memory and used as a variable, and doesn't interact with the script generation process. In addition, consider using double quote shell variables to avoid [word splitting](https://github.com/koalaman/shellcheck/wiki/SC2086), but this is [one of many](https://mywiki.wooledge.org/BashPitfalls) general recommendations for writing shell scripts, and is not specific to {% data variables.product.prodname_actions %}. +With this approach, the value of the {% raw %}`${{ github.event.pull_request.title }}`{% endraw %} expression is stored in memory and used as a variable, and doesn't interact with the script generation process. In addition, consider using double quote shell variables to avoid [word splitting](https://github.com/koalaman/shellcheck/wiki/SC2086), but this is [one of many](https://mywiki.wooledge.org/BashPitfalls) general recommendations for writing shell scripts, and is not specific to {% data variables.product.prodname_actions %}. ### Using workflow templates for {% data variables.product.prodname_code_scanning %} @@ -152,6 +152,34 @@ For more information, see [AUTOTITLE](/code-security/code-scanning/introduction- To help mitigate the risk of an exposed token, consider restricting the assigned permissions. For more information, see [AUTOTITLE](/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token). +## Understanding the risks of untrusted code checkout + +Similar to script injection attacks, untrusted pull request content that automatically triggers Actions processing can also pose a security risk. The `pull_request_target` and `workflow_run` workflow triggers, when used with the checkout of an untrusted pull request, expose the repository to security compromises. These workflows are privileged (i.e. they share the same cache of the main branch with other privileged workflow triggers, may have repository write access and access to referenced secrets), which can be exploited to take over a repository. + +Review the [`pull_request_target` trigger documentation](/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target) and the [`workflow_run` trigger documentation](/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflow-run) for more information on these triggers, how to use them, and the risks associated with them. + +For additional explanation, examples, and guidance on the risks of untrusted code checkout, see [Keeping your GitHub Actions and workflows secure: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/) from GitHub Security Lab and the [Dangerous Workflow check documentation](https://github.com/ossf/scorecard/blob/main/docs/checks.md#dangerous-workflow) from OpenSSF Scorecard. + +## Good practices for mitigating untrusted code checkout risks + +There are a number of different approaches available to help you mitigate the risk of untrusted code checkout in Actions workflows: + +### Avoid potentially dangerous workflow triggers + +Avoid using the `pull_request_target` workflow trigger if not necessary. Prefer using `workflow_run` for privilege separation between workflows as described in [Keeping your GitHub Actions and workflows secure: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests). Only use these workflow triggers when the workflow actually needs the privileged context. + +### Do not use the `pull_request_target` and `workflow_run` workflow triggers with untrusted content + +Avoid using the `pull_request_target` and `workflow_run` workflow triggers with untrusted pull requests or code content. Workflows that use these triggers must not explicitly checkout untrusted code, including from pull request forks or from repositories that are not under your control. Workflows triggered on `workflow_run` should treat artifacts uploaded from other workflows with caution (i.e. as untrusted). + +### Use CodeQL to detect potentially vulnerable workflows + +[CodeQL](/code-security/code-scanning/introduction-to-code-scanning/about-code-scanning-with-codeql) can scan and detect potentially vulnerable GitHub Actions workflows. [Configure the default setup for CodeQL](/code-security/code-scanning/enabling-code-scanning/configuring-default-setup-for-code-scanning) for the repository and ensure that GitHub Actions scanning is enabled. + +### Use OpenSSF Scorecards to detect potentially vulnerable workflows + +[OpenSSF Scorecards](#use-openssf-scorecards-to-detect-potentially-vulnerable-workflows) can help you identify potentially vulnerable workflows, along with other security risks when using GitHub Actions. + ## Managing permissions for {% data variables.product.prodname_actions %} settings in your organization You can practice the principle of least privilege for your organization's CI/CD pipeline with {% data variables.product.prodname_actions %} by administering custom organization roles. A custom organization role is a way to grant an individual or team in your organization the ability to control certain subsets of settings without granting full administrative control of the organization and its repositories. From 153ca4209ac5277c12e75dd6a51e96ffc337b18d Mon Sep 17 00:00:00 2001 From: Will Slattum Date: Mon, 14 Jul 2025 14:56:55 -0400 Subject: [PATCH 10/10] docs: fix grammar and improve content in reusables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jaroslav Lobačevski --- .../actions/pull-request-target-permissions-warning.md | 2 +- data/reusables/actions/workflow-run-permissions-warning.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/data/reusables/actions/pull-request-target-permissions-warning.md b/data/reusables/actions/pull-request-target-permissions-warning.md index c93fce14d35e..774ed93b95c9 100644 --- a/data/reusables/actions/pull-request-target-permissions-warning.md +++ b/data/reusables/actions/pull-request-target-permissions-warning.md @@ -1,2 +1,2 @@ > [!WARNING] -> For workflows that are triggered by the `pull_request_target` event, the `GITHUB_TOKEN` may be granted read/write repository permission (unless the `permissions` key is explicitly specified in the workflow or repository/organization default permission are set to Read-Only) and the workflow can access referenced secrets, even when it is triggered from a fork. Although the workflow runs in the context of the base of the pull request, you should be cautious if checking out untrusted code from the pull request with this event. Make sure that you do not build, or run untrusted code from the pull request. When `pull_request_target` is triggered against the main branch it shares the same cache as the other privileged workflows running in the context of the main branch. Running untrusted code on this trigger may lead to to cache poisoning. For more information, see [Understanding the risks of untrusted code checkout](/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#understanding-the-risks-of-untrusted-code-checkout) in the Security Hardening for GitHub Actions documentation and [Keeping your GitHub Actions and workflows secure: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests) on the GitHub Security Lab website. +> For workflows that are triggered by the `pull_request_target` event, the `GITHUB_TOKEN` may be granted read/write repository permission (unless the `permissions` key is explicitly specified in the workflow or repository/organization default permission are set to Read-Only) and the workflow can access referenced secrets, even when it is triggered from a fork. Although the workflow runs in the context of the base of the pull request, you should be cautious if checking out untrusted code from the pull request with this event. Make sure that you do not build, or run untrusted code from the pull request. When `pull_request_target` is triggered against the main branch it shares the same cache as the other privileged workflows running in the context of the main branch. Running untrusted code on this trigger may lead to cache poisoning. For more information, see [Understanding the risks of untrusted code checkout](/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#understanding-the-risks-of-untrusted-code-checkout) in the Security Hardening for GitHub Actions documentation and [Keeping your GitHub Actions and workflows secure: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests) on the GitHub Security Lab website. diff --git a/data/reusables/actions/workflow-run-permissions-warning.md b/data/reusables/actions/workflow-run-permissions-warning.md index 7ecbac9e71e0..a2822d8544bf 100644 --- a/data/reusables/actions/workflow-run-permissions-warning.md +++ b/data/reusables/actions/workflow-run-permissions-warning.md @@ -1,2 +1,2 @@ > [!WARNING] -> Workflows triggered by the `workflow_run` event are privileged (i.e. they share the same cache of the main branch with other privileged workflow triggers, may have repository write access and access to referenced secrets). You should make sure that you do not check out, build, or run untrusted code from the pull request or other untrusted sources with this event. The workflow shares the same cache as the other privileged workflows running in the context of the main branch. Running untrusted code on this trigger may lead to to cache poisoning. For more information, see [Understanding the risks of untrusted code checkout](/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#understanding-the-risks-of-untrusted-code-checkout) in the Security Hardening for GitHub Actions documentation and [Keeping your GitHub Actions and workflows secure: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests) on the GitHub Security Lab website. +> Workflows triggered by the `workflow_run` event are privileged (i.e. they share the same cache of the main branch with other privileged workflow triggers, may have repository write access and access to referenced secrets). You should make sure that you do not check out, build, or run untrusted code from the pull request or other untrusted sources with this event. The workflow shares the same cache as the other privileged workflows running in the context of the main branch. Running untrusted code on this trigger may lead to cache poisoning. For more information, see [Understanding the risks of untrusted code checkout](/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#understanding-the-risks-of-untrusted-code-checkout) in the Security Hardening for GitHub Actions documentation and [Keeping your GitHub Actions and workflows secure: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests) on the GitHub Security Lab website.