Skip to content

Commit 811ed3c

Browse files
authored
Merge pull request #19892 from owen-mc/fix-markdown-query-help-formatting
Fix markdown query help formatting
2 parents 219a622 + 2ed451c commit 811ed3c

33 files changed

+154
-198
lines changed

actions/ql/src/Security/CWE-077/EnvPathInjectionCritical.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# Environment Path Injection
2-
3-
## Description
1+
## Overview
42

53
GitHub Actions allow to define the system PATH variable by writing to a file pointed to by the `GITHUB_PATH` environment variable. Writing to this file appends a directory to the system PATH variable and automatically makes it available to all subsequent actions in the current job.
64

@@ -12,11 +10,11 @@ echo "$HOME/.local/bin" >> $GITHUB_PATH
1210

1311
If an attacker can control the contents of the system PATH, they are able to influence what commands are run in subsequent steps of the same job.
1412

15-
## Recommendations
13+
## Recommendation
1614

1715
Do not allow untrusted data to influence the system PATH: Avoid using untrusted data sources (e.g., artifact content) to define the system PATH.
1816

19-
## Examples
17+
## Example
2018

2119
### Incorrect Usage
2220

@@ -36,4 +34,4 @@ If an attacker can manipulate the value being set, such as through artifact down
3634
3735
## References
3836
39-
- [Workflow commands for GitHub Actions](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions)
37+
- GitHub Docs: [Workflow commands for GitHub Actions](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions).

actions/ql/src/Security/CWE-077/EnvPathInjectionMedium.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# Environment Path Injection
2-
3-
## Description
1+
## Overview
42

53
GitHub Actions allow to define the system PATH variable by writing to a file pointed to by the `GITHUB_PATH` environment variable. Writing to this file appends a directory to the system PATH variable and automatically makes it available to all subsequent actions in the current job.
64

@@ -12,11 +10,11 @@ echo "$HOME/.local/bin" >> $GITHUB_PATH
1210

1311
If an attacker can control the contents of the system PATH, they are able to influence what commands are run in subsequent steps of the same job.
1412

15-
## Recommendations
13+
## Recommendation
1614

1715
Do not allow untrusted data to influence the system PATH: Avoid using untrusted data sources (e.g., artifact content) to define the system PATH.
1816

19-
## Examples
17+
## Example
2018

2119
### Incorrect Usage
2220

@@ -36,4 +34,4 @@ If an attacker can manipulate the value being set, such as through artifact down
3634
3735
## References
3836
39-
- [Workflow commands for GitHub Actions](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions)
37+
- GitHub Docs: [Workflow commands for GitHub Actions](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions).

actions/ql/src/Security/CWE-077/EnvVarInjectionCritical.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# Environment Variable Injection
2-
3-
## Description
1+
## Overview
42

53
GitHub Actions allow to define environment variables by writing to a file pointed to by the `GITHUB_ENV` environment variable:
64

@@ -37,7 +35,7 @@ steps:
3735

3836
If an attacker can control the values assigned to environment variables and there is no sanitization in place, the attacker will be able to inject additional variables by injecting new lines or `{delimiters}`.
3937

40-
## Recommendations
38+
## Recommendation
4139

4240
1. **Do not allow untrusted data to influence environment variables**:
4341

@@ -64,7 +62,7 @@ If an attacker can control the values assigned to environment variables and ther
6462
} >> "$GITHUB_ENV"
6563
```
6664

67-
## Examples
65+
## Example
6866

6967
### Example of Vulnerability
7068

@@ -113,5 +111,5 @@ An attacker is be able to run arbitrary code by injecting environment variables
113111
114112
## References
115113
116-
- [Workflow commands for GitHub Actions](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions)
117-
- [GitHub Actions Exploitation: Repo Jacking and Environment Manipulation](https://www.synacktiv.com/publications/github-actions-exploitation-repo-jacking-and-environment-manipulation)
114+
- GitHub Docs: [Workflow commands for GitHub Actions](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions).
115+
- Synacktiv: [GitHub Actions Exploitation: Repo Jacking and Environment Manipulation](https://www.synacktiv.com/publications/github-actions-exploitation-repo-jacking-and-environment-manipulation).

actions/ql/src/Security/CWE-077/EnvVarInjectionMedium.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# Environment Variable Injection
2-
3-
## Description
1+
## Overview
42

53
GitHub Actions allow to define environment variables by writing to a file pointed to by the `GITHUB_ENV` environment variable:
64

@@ -37,7 +35,7 @@ steps:
3735

3836
If an attacker can control the values assigned to environment variables and there is no sanitization in place, the attacker will be able to inject additional variables by injecting new lines or `{delimiters}`.
3937

40-
## Recommendations
38+
## Recommendation
4139

4240
1. **Do not allow untrusted data to influence environment variables**:
4341

@@ -64,7 +62,7 @@ If an attacker can control the values assigned to environment variables and ther
6462
} >> "$GITHUB_ENV"
6563
```
6664

67-
## Examples
65+
## Example
6866

6967
### Example of Vulnerability
7068

@@ -113,5 +111,5 @@ An attacker would be able to run arbitrary code by injecting environment variabl
113111
114112
## References
115113
116-
- [Workflow commands for GitHub Actions](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions)
117-
- [GitHub Actions Exploitation: Repo Jacking and Environment Manipulation](https://www.synacktiv.com/publications/github-actions-exploitation-repo-jacking-and-environment-manipulation)
114+
- GitHub Docs: [Workflow commands for GitHub Actions](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions).
115+
- Synacktiv: [GitHub Actions Exploitation: Repo Jacking and Environment Manipulation](https://www.synacktiv.com/publications/github-actions-exploitation-repo-jacking-and-environment-manipulation).

actions/ql/src/Security/CWE-094/CodeInjectionCritical.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
# Code Injection in GitHub Actions
2-
3-
## Description
1+
## Overview
42

53
Using user-controlled input in GitHub Actions may lead to code injection in contexts like _run:_ or _script:_.
64

75
Code injection in GitHub Actions may allow an attacker to exfiltrate any secrets used in the workflow and the temporary GitHub repository authorization token. The token may have write access to the repository, allowing an attacker to make changes to the repository.
86

9-
## Recommendations
7+
## Recommendation
108

119
The best practice to avoid code injection vulnerabilities in GitHub workflows is to set the untrusted input value of the expression to an intermediate environment variable and then use the environment variable using the native syntax of the shell/script interpreter (that is, not _${{ env.VAR }}_).
1210

1311
It is also recommended to limit the permissions of any tokens used by a workflow such as the GITHUB_TOKEN.
1412

15-
## Examples
13+
## Example
1614

1715
### Incorrect Usage
1816

actions/ql/src/Security/CWE-094/CodeInjectionMedium.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
# Code Injection in GitHub Actions
2-
3-
## Description
1+
## Overview
42

53
Using user-controlled input in GitHub Actions may lead to code injection in contexts like _run:_ or _script:_.
64

75
Code injection in GitHub Actions may allow an attacker to exfiltrate any secrets used in the workflow and the temporary GitHub repository authorization token. The token may have write access to the repository, allowing an attacker to make changes to the repository.
86

9-
## Recommendations
7+
## Recommendation
108

119
The best practice to avoid code injection vulnerabilities in GitHub workflows is to set the untrusted input value of the expression to an intermediate environment variable and then use the environment variable using the native syntax of the shell/script interpreter (that is, not _${{ env.VAR }}_).
1210

1311
It is also recommended to limit the permissions of any tokens used by a workflow such as the GITHUB_TOKEN.
1412

15-
## Examples
13+
## Example
1614

1715
### Incorrect Usage
1816

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
# Use of Actions with known vulnerabilities
2-
3-
## Description
1+
## Overview
42

53
The security of the workflow and the repository could be compromised by GitHub Actions workflows that utilize GitHub Actions with known vulnerabilities.
64

7-
## Recommendations
5+
## Recommendation
86

97
Either remove the component from the workflow or upgrade it to a version that is not vulnerable.
108

119
## References
1210

13-
- [GitHub Docs: Keeping your actions up to date with Dependabot](https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot)
11+
- GitHub Docs: [Keeping your actions up to date with Dependabot](https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot).

actions/ql/src/Security/CWE-275/MissingActionsPermissions.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
# Actions Job and Workflow Permissions are not set
2-
3-
## Description
1+
## Overview
42

53
If a GitHub Actions job or workflow has no explicit permissions set, then the repository permissions are used. Repositories created under organizations inherit the organization permissions. The organizations or repositories created before February 2023 have the default permissions set to read-write. Often these permissions do not adhere to the principle of least privilege and can be reduced to read-only, leaving the `write` permission only to a specific types as `issues: write` or `pull-requests: write`.
64

7-
## Recommendations
5+
## Recommendation
6+
7+
Add the `permissions` key to the job or the root of workflow (in this case it is applied to all jobs in the workflow that do not have their own `permissions` key) and assign the least privileges required to complete the task.
8+
9+
## Example
10+
11+
### Incorrect Usage
12+
13+
```yaml
14+
name: "My workflow"
15+
# No permissions block
16+
```
817

9-
Add the `permissions` key to the job or the root of workflow (in this case it is applied to all jobs in the workflow that do not have their own `permissions` key) and assign the least privileges required to complete the task:
18+
### Correct Usage
1019

1120
```yaml
1221
name: "My workflow"
@@ -27,4 +36,4 @@ jobs:
2736
2837
## References
2938
30-
- [Assigning permissions to jobs](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/assigning-permissions-to-jobs)
39+
- GitHub Docs: [Assigning permissions to jobs](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/assigning-permissions-to-jobs).

actions/ql/src/Security/CWE-285/ImproperAccessControl.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
# Improper Access Control
2-
3-
## Description
1+
## Overview
42

53
Sometimes labels are used to approve GitHub Actions. An authorization check may not be properly implemented, allowing an attacker to mutate the code after it has been reviewed and approved by label.
64

7-
## Recommendations
5+
## Recommendation
86

97
When using labels, make sure that the code cannot be modified after it has been reviewed and the label has been set.
108

11-
## Examples
9+
## Example
1210

1311
### Incorrect Usage
1412

@@ -57,4 +55,4 @@ jobs:
5755

5856
## References
5957

60-
- [Events that trigger workflows](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target)
58+
- GitHub Docs: [Events that trigger workflows](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target).

actions/ql/src/Security/CWE-312/ExcessiveSecretsExposure.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
# Excessive Secrets Exposure
2-
3-
## Description
1+
## Overview
42

53
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.
64

7-
## Recommendations
5+
## Recommendation
86

97
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.
108

11-
## Examples
9+
## Example
1210

1311
### Incorrect Usage
1412

@@ -48,5 +46,5 @@ env:
4846
4947
## References
5048
51-
- [Using secrets in GitHub Actions](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#using-encrypted-secrets-in-a-workflow)
52-
- [Job uses all secrets](https://github.com/boostsecurityio/poutine/blob/main/docs/content/en/rules/job_all_secrets.md)
49+
- GitHub Docs: [Using secrets in GitHub Actions](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#using-encrypted-secrets-in-a-workflow).
50+
- poutine: [Job uses all secrets](https://github.com/boostsecurityio/poutine/blob/main/docs/content/en/rules/job_all_secrets.md).

actions/ql/src/Security/CWE-312/SecretsInArtifacts.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# Storage of sensitive information in GitHub Actions artifact
2-
3-
## Description
1+
## Overview
42

53
Sensitive information included in a GitHub Actions artifact can allow an attacker to access the sensitive information if the artifact is published.
64

@@ -10,6 +8,8 @@ Only store information that is meant to be publicly available in a GitHub Action
108

119
## Example
1210

11+
### Incorrect Usage
12+
1313
The following example uses `actions/checkout` to checkout code which stores the GITHUB_TOKEN in the \`.git/config\` file and then stores the contents of the \`.git\` repository into the artifact:
1414

1515
```yaml
@@ -28,6 +28,8 @@ jobs:
2828
path: .
2929
```
3030
31+
### Correct Usage
32+
3133
The issue has been fixed below, where the `actions/upload-artifact` uses a version (v4+) which does not include hidden files or directories into the artifact.
3234

3335
```yaml

actions/ql/src/Security/CWE-312/UnmaskedSecretExposure.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
# Unmasked Secret Exposure
2-
3-
## Description
1+
## Overview
42

53
Secrets derived from other secrets are not known to the workflow runner, and therefore are not masked unless explicitly registered.
64

7-
## Recommendations
5+
## Recommendation
86

97
Avoid defining non-plain secrets. For example, do not define a new secret containing a JSON object and then read properties out of it from the workflow, since these read values will not be masked by the workflow runner.
108

11-
## Examples
9+
## Example
1210

1311
### Incorrect Usage
1412

@@ -34,4 +32,4 @@ Avoid defining non-plain secrets. For example, do not define a new secret contai
3432
3533
## References
3634
37-
- [Using secrets in GitHub Actions](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#using-encrypted-secrets-in-a-workflow)
35+
- GitHub Docs: [Using secrets in GitHub Actions](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#using-encrypted-secrets-in-a-workflow).

actions/ql/src/Security/CWE-349/CachePoisoningViaCodeInjection.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# Cache Poisoning in GitHub Actions
2-
3-
## Description
1+
## Overview
42

53
GitHub Actions cache poisoning is a technique that allows an attacker to inject malicious content into the Action's cache from unprivileged workflow, potentially leading to code execution in privileged workflows.
64

@@ -23,7 +21,7 @@ In GitHub Actions, cache scopes are primarily determined by the branch structure
2321

2422
Due to the above design, if something is cached in the context of the default branch (e.g., `main`), it becomes accessible to any feature branch derived from `main`.
2523

26-
## Recommendations
24+
## Recommendation
2725

2826
1. Avoid using caching in workflows that handle sensitive operations like releases.
2927
2. If caching must be used:
@@ -34,7 +32,7 @@ Due to the above design, if something is cached in the context of the default br
3432
4. Never run untrusted code in the context of the default branch.
3533
5. Sign the cache value cryptographically and verify the signature before usage.
3634

37-
## Examples
35+
## Example
3836

3937
### Incorrect Usage
4038

@@ -78,6 +76,6 @@ jobs:
7876
7977
## References
8078
81-
- [The Monsters in Your Build Cache – GitHub Actions Cache Poisoning](https://adnanthekhan.com/2024/05/06/the-monsters-in-your-build-cache-github-actions-cache-poisoning/)
82-
- [GitHub Actions Caching Documentation](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows)
83-
- [Cache Poisoning in GitHub Actions](https://scribesecurity.com/blog/github-cache-poisoning/)
79+
- Adnan Khan's Blog: [The Monsters in Your Build Cache – GitHub Actions Cache Poisoning](https://adnanthekhan.com/2024/05/06/the-monsters-in-your-build-cache-github-actions-cache-poisoning/).
80+
- GitHub Docs: [GitHub Actions Caching Documentation](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows).
81+
- Scribe Security Blog: [Cache Poisoning in GitHub Actions](https://scribesecurity.com/blog/github-cache-poisoning/).

actions/ql/src/Security/CWE-349/CachePoisoningViaDirectCache.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# Cache Poisoning in GitHub Actions
2-
3-
## Description
1+
## Overview
42

53
GitHub Actions cache poisoning is a technique that allows an attacker to inject malicious content into the Action's cache from unprivileged workflow, potentially leading to code execution in privileged workflows.
64

@@ -23,7 +21,7 @@ In GitHub Actions, cache scopes are primarily determined by the branch structure
2321

2422
Due to the above design, if something is cached in the context of the default branch (e.g., `main`), it becomes accessible to any feature branch derived from `main`.
2523

26-
## Recommendations
24+
## Recommendation
2725

2826
1. Avoid using caching in workflows that handle sensitive operations like releases.
2927
2. If caching must be used:
@@ -34,7 +32,7 @@ Due to the above design, if something is cached in the context of the default br
3432
4. Never run untrusted code in the context of the default branch.
3533
5. Sign the cache value cryptographically and verify the signature before usage.
3634

37-
## Examples
35+
## Example
3836

3937
### Incorrect Usage
4038

@@ -123,6 +121,6 @@ jobs:
123121

124122
## References
125123

126-
- [The Monsters in Your Build Cache – GitHub Actions Cache Poisoning](https://adnanthekhan.com/2024/05/06/the-monsters-in-your-build-cache-github-actions-cache-poisoning/)
127-
- [GitHub Actions Caching Documentation](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows)
128-
- [Cache Poisoning in GitHub Actions](https://scribesecurity.com/blog/github-cache-poisoning/)
124+
- Adnan Khan's Blog: [The Monsters in Your Build Cache – GitHub Actions Cache Poisoning](https://adnanthekhan.com/2024/05/06/the-monsters-in-your-build-cache-github-actions-cache-poisoning/).
125+
- GitHub Docs: [GitHub Actions Caching Documentation](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows).
126+
- Scribe Security Blog: [Cache Poisoning in GitHub Actions](https://scribesecurity.com/blog/github-cache-poisoning/).

0 commit comments

Comments
 (0)