Skip to content

Fix markdown query help formatting #19892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions actions/ql/src/Security/CWE-077/EnvPathInjectionCritical.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Environment Path Injection

## Description
## Overview

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.

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

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.

## Recommendations
## Recommendation

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

## Examples
## Example

### Incorrect Usage

Expand All @@ -36,4 +34,4 @@ If an attacker can manipulate the value being set, such as through artifact down

## References

- [Workflow commands for GitHub Actions](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions)
- 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).
10 changes: 4 additions & 6 deletions actions/ql/src/Security/CWE-077/EnvPathInjectionMedium.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Environment Path Injection

## Description
## Overview

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.

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

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.

## Recommendations
## Recommendation

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

## Examples
## Example

### Incorrect Usage

Expand All @@ -36,4 +34,4 @@ If an attacker can manipulate the value being set, such as through artifact down

## References

- [Workflow commands for GitHub Actions](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions)
- 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).
12 changes: 5 additions & 7 deletions actions/ql/src/Security/CWE-077/EnvVarInjectionCritical.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Environment Variable Injection

## Description
## Overview

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

Expand Down Expand Up @@ -37,7 +35,7 @@ steps:

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}`.

## Recommendations
## Recommendation

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

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

## Examples
## Example

### Example of Vulnerability

Expand Down Expand Up @@ -113,5 +111,5 @@ An attacker is be able to run arbitrary code by injecting environment variables

## References

- [Workflow commands for GitHub Actions](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions)
- [GitHub Actions Exploitation: Repo Jacking and Environment Manipulation](https://www.synacktiv.com/publications/github-actions-exploitation-repo-jacking-and-environment-manipulation)
- 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).
- Synacktiv: [GitHub Actions Exploitation: Repo Jacking and Environment Manipulation](https://www.synacktiv.com/publications/github-actions-exploitation-repo-jacking-and-environment-manipulation).
12 changes: 5 additions & 7 deletions actions/ql/src/Security/CWE-077/EnvVarInjectionMedium.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Environment Variable Injection

## Description
## Overview

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

Expand Down Expand Up @@ -37,7 +35,7 @@ steps:

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}`.

## Recommendations
## Recommendation

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

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

## Examples
## Example

### Example of Vulnerability

Expand Down Expand Up @@ -113,5 +111,5 @@ An attacker would be able to run arbitrary code by injecting environment variabl

## References

- [Workflow commands for GitHub Actions](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions)
- [GitHub Actions Exploitation: Repo Jacking and Environment Manipulation](https://www.synacktiv.com/publications/github-actions-exploitation-repo-jacking-and-environment-manipulation)
- 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).
- Synacktiv: [GitHub Actions Exploitation: Repo Jacking and Environment Manipulation](https://www.synacktiv.com/publications/github-actions-exploitation-repo-jacking-and-environment-manipulation).
8 changes: 3 additions & 5 deletions actions/ql/src/Security/CWE-094/CodeInjectionCritical.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# Code Injection in GitHub Actions

## Description
## Overview

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

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.

## Recommendations
## Recommendation

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 }}_).

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

## Examples
## Example

### Incorrect Usage

Expand Down
8 changes: 3 additions & 5 deletions actions/ql/src/Security/CWE-094/CodeInjectionMedium.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# Code Injection in GitHub Actions

## Description
## Overview

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

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.

## Recommendations
## Recommendation

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 }}_).

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

## Examples
## Example

### Incorrect Usage

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Use of Actions with known vulnerabilities

## Description
## Overview

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

## Recommendations
## Recommendation

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

## References

- [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)
- 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).
21 changes: 15 additions & 6 deletions actions/ql/src/Security/CWE-275/MissingActionsPermissions.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
# Actions Job and Workflow Permissions are not set

## Description
## Overview

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`.

## Recommendations
## Recommendation

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.

## Example

### Incorrect Usage

```yaml
name: "My workflow"
# No permissions block
```

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:
### Correct Usage

```yaml
name: "My workflow"
Expand All @@ -27,4 +36,4 @@ jobs:

## References

- [Assigning permissions to jobs](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/assigning-permissions-to-jobs)
- GitHub Docs: [Assigning permissions to jobs](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/assigning-permissions-to-jobs).
10 changes: 4 additions & 6 deletions actions/ql/src/Security/CWE-285/ImproperAccessControl.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Improper Access Control

## Description
## Overview

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.

## Recommendations
## Recommendation

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

## Examples
## Example

### Incorrect Usage

Expand Down Expand Up @@ -57,4 +55,4 @@ jobs:

## References

- [Events that trigger workflows](https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request_target)
- 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).
12 changes: 5 additions & 7 deletions actions/ql/src/Security/CWE-312/ExcessiveSecretsExposure.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Excessive Secrets Exposure

## Description
## 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.

## Recommendations
## 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.

## Examples
## Example

### Incorrect Usage

Expand Down Expand Up @@ -48,5 +46,5 @@ env:

## References

- [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)
- [Job uses all secrets](https://github.com/boostsecurityio/poutine/blob/main/docs/content/en/rules/job_all_secrets.md)
- 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).
- poutine: [Job uses all secrets](https://github.com/boostsecurityio/poutine/blob/main/docs/content/en/rules/job_all_secrets.md).
8 changes: 5 additions & 3 deletions actions/ql/src/Security/CWE-312/SecretsInArtifacts.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Storage of sensitive information in GitHub Actions artifact

## Description
## Overview

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

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

## Example

### Incorrect Usage

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:

```yaml
Expand All @@ -28,6 +28,8 @@ jobs:
path: .
```

### Correct Usage

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.

```yaml
Expand Down
10 changes: 4 additions & 6 deletions actions/ql/src/Security/CWE-312/UnmaskedSecretExposure.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# Unmasked Secret Exposure

## Description
## Overview

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

## Recommendations
## Recommendation

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.

## Examples
## Example

### Incorrect Usage

Expand All @@ -34,4 +32,4 @@ Avoid defining non-plain secrets. For example, do not define a new secret contai

## References

- [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)
- 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).
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Cache Poisoning in GitHub Actions

## Description
## Overview

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.

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

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`.

## Recommendations
## Recommendation

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

## Examples
## Example

### Incorrect Usage

Expand Down Expand Up @@ -78,6 +76,6 @@ jobs:

## References

- [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/)
- [GitHub Actions Caching Documentation](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows)
- [Cache Poisoning in GitHub Actions](https://scribesecurity.com/blog/github-cache-poisoning/)
- 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/).
- GitHub Docs: [GitHub Actions Caching Documentation](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows).
- Scribe Security Blog: [Cache Poisoning in GitHub Actions](https://scribesecurity.com/blog/github-cache-poisoning/).
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# Cache Poisoning in GitHub Actions

## Description
## Overview

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.

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

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`.

## Recommendations
## Recommendation

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

## Examples
## Example

### Incorrect Usage

Expand Down Expand Up @@ -123,6 +121,6 @@ jobs:

## References

- [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/)
- [GitHub Actions Caching Documentation](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows)
- [Cache Poisoning in GitHub Actions](https://scribesecurity.com/blog/github-cache-poisoning/)
- 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/).
- GitHub Docs: [GitHub Actions Caching Documentation](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows).
- Scribe Security Blog: [Cache Poisoning in GitHub Actions](https://scribesecurity.com/blog/github-cache-poisoning/).
Loading
Loading