Skip to content

Commit c4d70e6

Browse files
author
Alvaro Muñoz
committed
Bump qlpack versions
1 parent 822a326 commit c4d70e6

File tree

4 files changed

+122
-2
lines changed

4 files changed

+122
-2
lines changed

ql/lib/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
library: true
33
warnOnImplicitThis: true
44
name: github/actions-all
5-
version: 0.1.29
5+
version: 0.1.30
66
dependencies:
77
codeql/util: ^1.0.1
88
codeql/yaml: ^1.0.1
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Code Injection in GitHub Actions
2+
3+
Using user-controlled input in GitHub Actions may lead to code injection in contexts like _run:_ or _script:_.
4+
5+
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 might have write access to the repository, allowing an attacker to use the token to make changes to the repository.
6+
7+
## Recommendation
8+
9+
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 }}_).
10+
11+
It is also recommended to limit the permissions of any tokens used by a workflow such as the GITHUB_TOKEN.
12+
13+
## Example
14+
15+
The following example lets a user inject an arbitrary shell command:
16+
17+
```yaml
18+
on: issue_comment
19+
20+
jobs:
21+
echo-body:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- run: |
25+
echo '${{ github.event.comment.body }}'
26+
```
27+
28+
The following example uses an environment variable, but **still allows the injection** because of the use of expression syntax:
29+
30+
```yaml
31+
on: issue_comment
32+
33+
jobs:
34+
echo-body:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- env:
38+
BODY: ${{ github.event.issue.body }}
39+
run: |
40+
echo '${{ env.BODY }}'
41+
```
42+
43+
The following example uses shell syntax to read the environment variable and will prevent the attack:
44+
45+
```yaml
46+
jobs:
47+
echo-body:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- env:
51+
BODY: ${{ github.event.issue.body }}
52+
run: |
53+
echo "$BODY"
54+
```
55+
56+
## References
57+
58+
- GitHub Security Lab Research: [Keeping your GitHub Actions and workflows secure: Untrusted input](https://securitylab.github.com/research/github-actions-untrusted-input).
59+
- GitHub Docs: [Security hardening for GitHub Actions](https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions).
60+
- GitHub Docs: [Permissions for the GITHUB_TOKEN](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token).
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Code Injection in GitHub Actions
2+
3+
Using user-controlled input in GitHub Actions may lead to code injection in contexts like _run:_ or _script:_.
4+
5+
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 might have write access to the repository, allowing an attacker to use the token to make changes to the repository.
6+
7+
## Recommendation
8+
9+
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 }}_).
10+
11+
It is also recommended to limit the permissions of any tokens used by a workflow such as the GITHUB_TOKEN.
12+
13+
## Example
14+
15+
The following example lets a user inject an arbitrary shell command:
16+
17+
```yaml
18+
on: issue_comment
19+
20+
jobs:
21+
echo-body:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- run: |
25+
echo '${{ github.event.comment.body }}'
26+
```
27+
28+
The following example uses an environment variable, but **still allows the injection** because of the use of expression syntax:
29+
30+
```yaml
31+
on: issue_comment
32+
33+
jobs:
34+
echo-body:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- env:
38+
BODY: ${{ github.event.issue.body }}
39+
run: |
40+
echo '${{ env.BODY }}'
41+
```
42+
43+
The following example uses shell syntax to read the environment variable and will prevent the attack:
44+
45+
```yaml
46+
jobs:
47+
echo-body:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- env:
51+
BODY: ${{ github.event.issue.body }}
52+
run: |
53+
echo "$BODY"
54+
```
55+
56+
## References
57+
58+
- GitHub Security Lab Research: [Keeping your GitHub Actions and workflows secure: Untrusted input](https://securitylab.github.com/research/github-actions-untrusted-input).
59+
- GitHub Docs: [Security hardening for GitHub Actions](https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions).
60+
- GitHub Docs: [Permissions for the GITHUB_TOKEN](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token).

ql/src/qlpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
library: false
33
name: github/actions-queries
4-
version: 0.1.29
4+
version: 0.1.30
55
groups: [actions, queries]
66
suites: codeql-suites
77
extractor: javascript

0 commit comments

Comments
 (0)