Skip to content

Commit 4fd0222

Browse files
committed
Update help files CWE-829/UntrustedCheckoutX
1 parent 81532c7 commit 4fd0222

3 files changed

Lines changed: 93 additions & 3 deletions

File tree

actions/ql/src/Security/CWE-829/UntrustedCheckoutCritical.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
11
## Overview
22

3-
GitHub workflows can be triggered through various repository events, including incoming pull requests (PRs) or comments on Issues/PRs. A dangerous misuse of event triggers such as `pull_request_target` or `issue_comment` followed by an explicit checkout of untrusted input from the PR may lead to repository compromise if untrusted code gets executed in a privileged job. Untrusted code may get executed due to a modified build script, workflow injection, or registry hijacking. **Carefully review** whether least privileges is used and whether input is taken from untrusted sources.
3+
GitHub workflows can be triggered through various repository events, including incoming pull requests (PRs) or comments on Issues/PRs. Under certain conditions described below, attackers can take over a repository by opening malicious PRs from forks. The attacks can result in malicious code execution causing unauthorized changes to the repository or exfiltration of repository secrets and a compromise of connected systems.
4+
5+
## Workflow Security Model
6+
7+
In GitHub Actions, there is a distinction between unprivileged and privileged workflows. For example, a workflow with a `pull_request` trigger is unprivileged while a workflow with `pull_request_target` is privileged.
8+
9+
This is relevant especially for PRs from forks. Normal PRs can only be submitted by people who have write access to a repository, while PRs from forks can be submitted by anyone.
10+
11+
On a PR from a fork, an unprivileged `pull_request` workflow has only limited capabilities but a privileged `pull_request_target` workflow is much more dangerous. A privileged workflow:
12+
13+
* Runs in the context of the base repository
14+
* Has access to organization and repository secrets (e.g., API keys, deployment tokens)
15+
* Has a read/write `GITHUB_TOKEN` by default
16+
* Can access private resources
17+
18+
Certain triggers automatically grant a workflow elevated privileges:
19+
20+
* `pull_request_target` as described above
21+
* `workflow_run`: Triggered when another workflow completes.
22+
* `issue_comment`: Triggered when a comment is made on an issue or PR.
23+
24+
## Attack Details
25+
26+
* A repository has a privileged workflow
27+
* An attacker forks the repository and adds malicious code (e.g., in the build script)
28+
* The attacker opens a PR from the fork, and, if needed, comments on the PR
29+
* The workflow in the base repository checks out the forked code
30+
* The workflow runs, (e.g. the build script etc.), which contains the malicious code
31+
32+
Please note that not only build scripts can be malicious code vectors. There is a large number of other possibilities. Some of them are listed in the [LOTP](https://boostsecurityio.github.io/lotp/) catalog.
433

534
## Recommendation
635

@@ -133,4 +162,5 @@ jobs:
133162
## References
134163
135164
- GitHub Security Lab Research: [Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/).
165+
- Mitigating risks of untrusted checkout: [GitHub Docs](https://docs.github.com/en/enterprise-cloud@latest/actions/reference/security/secure-use#mitigating-the-risks-of-untrusted-code-checkout).
136166
- Living Off the Pipeline: [LOTP](https://boostsecurityio.github.io/lotp/).

actions/ql/src/Security/CWE-829/UntrustedCheckoutHigh.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
11
## Overview
22

3-
GitHub workflows can be triggered through various repository events, including incoming pull requests (PRs) or comments on Issues/PRs. A dangerous misuse of event triggers such as `pull_request_target` or `issue_comment` followed by an explicit checkout of untrusted input from the PR may lead to repository compromise if untrusted code gets executed in a privileged job. Untrusted code may get executed due to a modified build script, workflow injection, or registry hijacking. **Carefully review** whether least privileges is used and whether input is taken from untrusted sources.
3+
GitHub workflows can be triggered through various repository events, including incoming pull requests (PRs) or comments on Issues/PRs. Under certain conditions described below, attackers can take over a repository by opening malicious PRs from forks. The attacks can result in malicious code execution causing unauthorized changes to the repository or exfiltration of repository secrets and a compromise of connected systems.
4+
5+
## Workflow Security Model
6+
7+
In GitHub Actions, there is a distinction between unprivileged and privileged workflows. For example, a workflow with a `pull_request` trigger is unprivileged while a workflow with `pull_request_target` is privileged.
8+
9+
This is relevant especially for PRs from forks. Normal PRs can only be submitted by people who have write access to a repository, while PRs from forks can be submitted by anyone.
10+
11+
On a PR from a fork, an unprivileged `pull_request` workflow has only limited capabilities but a privileged `pull_request_target` workflow is much more dangerous. A privileged workflow:
12+
13+
* Runs in the context of the base repository
14+
* Has access to organization and repository secrets (e.g., API keys, deployment tokens)
15+
* Has a read/write `GITHUB_TOKEN` by default
16+
* Can access private resources
17+
18+
Certain triggers automatically grant a workflow elevated privileges:
19+
20+
* `pull_request_target` as described above
21+
* `workflow_run`: Triggered when another workflow completes.
22+
* `issue_comment`: Triggered when a comment is made on an issue or PR.
23+
24+
## Attack Details
25+
26+
* A repository has a privileged workflow
27+
* An attacker forks the repository and adds malicious code (e.g., in the build script)
28+
* The attacker opens a PR from the fork, and, if needed, comments on the PR
29+
* The workflow in the base repository checks out the forked code
30+
* The workflow runs, (e.g. the build script etc.), which contains the malicious code
31+
32+
Please note that not only build scripts can be malicious code vectors. There is a large number of other possibilities. Some of them are listed in the [LOTP](https://boostsecurityio.github.io/lotp/) catalog.
433

534
## Recommendation
635

@@ -133,4 +162,5 @@ jobs:
133162
## References
134163
135164
- GitHub Security Lab Research: [Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/).
165+
- Mitigating risks of untrusted checkout: [GitHub Docs](https://docs.github.com/en/enterprise-cloud@latest/actions/reference/security/secure-use#mitigating-the-risks-of-untrusted-code-checkout).
136166
- Living Off the Pipeline: [LOTP](https://boostsecurityio.github.io/lotp/).

actions/ql/src/Security/CWE-829/UntrustedCheckoutMedium.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,35 @@
11
## Overview
22

3-
GitHub workflows can be triggered through various repository events, including incoming pull requests (PRs) or comments on Issues/PRs. A dangerous misuse of event triggers such as `pull_request_target` or `issue_comment` followed by an explicit checkout of untrusted input from the PR may lead to repository compromise if untrusted code gets executed in a privileged job. Untrusted code may get executed due to a modified build script, workflow injection, or registry hijacking. **Carefully review** whether least privileges is used and whether input is taken from untrusted sources.
3+
GitHub workflows can be triggered through various repository events, including incoming pull requests (PRs) or comments on Issues/PRs. Under certain conditions described below, attackers can take over a repository by opening malicious PRs from forks. The attacks can result in malicious code execution causing unauthorized changes to the repository or exfiltration of repository secrets and a compromise of connected systems.
4+
5+
## Workflow Security Model
6+
7+
In GitHub Actions, there is a distinction between unprivileged and privileged workflows. For example, a workflow with a `pull_request` trigger is unprivileged while a workflow with `pull_request_target` is privileged.
8+
9+
This is relevant especially for PRs from forks. Normal PRs can only be submitted by people who have write access to a repository, while PRs from forks can be submitted by anyone.
10+
11+
On a PR from a fork, an unprivileged `pull_request` workflow has only limited capabilities but a privileged `pull_request_target` workflow is much more dangerous. A privileged workflow:
12+
13+
* Runs in the context of the base repository
14+
* Has access to organization and repository secrets (e.g., API keys, deployment tokens)
15+
* Has a read/write `GITHUB_TOKEN` by default
16+
* Can access private resources
17+
18+
Certain triggers automatically grant a workflow elevated privileges:
19+
20+
* `pull_request_target` as described above
21+
* `workflow_run`: Triggered when another workflow completes.
22+
* `issue_comment`: Triggered when a comment is made on an issue or PR.
23+
24+
## Attack Details
25+
26+
* A repository has a privileged workflow
27+
* An attacker forks the repository and adds malicious code (e.g., in the build script)
28+
* The attacker opens a PR from the fork, and, if needed, comments on the PR
29+
* The workflow in the base repository checks out the forked code
30+
* The workflow runs, (e.g. the build script etc.), which contains the malicious code
31+
32+
Please note that not only build scripts can be malicious code vectors. There is a large number of other possibilities. Some of them are listed in the [LOTP](https://boostsecurityio.github.io/lotp/) catalog.
433

534
## Recommendation
635

@@ -133,4 +162,5 @@ jobs:
133162
## References
134163
135164
- GitHub Security Lab Research: [Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/).
165+
- Mitigating risks of untrusted checkout: [GitHub Docs](https://docs.github.com/en/enterprise-cloud@latest/actions/reference/security/secure-use#mitigating-the-risks-of-untrusted-code-checkout).
136166
- Living Off the Pipeline: [LOTP](https://boostsecurityio.github.io/lotp/).

0 commit comments

Comments
 (0)