Skip to content

Commit a282818

Browse files
committed
grammar
1 parent 77ecca9 commit a282818

File tree

4 files changed

+60
-60
lines changed

4 files changed

+60
-60
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Description
44

5-
GitHub Actions allow to define the system PATH variable by writing to a file pointed 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.
5+
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.
66

77
E.g.:
88

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Description
44

5-
GitHub Actions allow to define the system PATH variable by writing to a file pointed 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.
5+
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.
66

77
E.g.:
88

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

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
## Description
44

5-
GitHub Actions allow to define Environment Variables by writing to a file pointed to by the `GITHUB_ENV` environment variable:
5+
GitHub Actions allow to define environment variables by writing to a file pointed to by the `GITHUB_ENV` environment variable:
66

7-
This file should lines in the `KEY=VALUE` format:
7+
This file contains lines in the `KEY=VALUE` format:
88

99
```bash
1010
steps:
@@ -14,7 +14,7 @@ steps:
1414
echo "action_state=yellow" >> "$GITHUB_ENV"
1515
```
1616

17-
It is also possible to define a multiline variables by using the following format:
17+
It is also possible to define multiline variables by using the [following construct](https://en.wikipedia.org/wiki/Here_document):
1818

1919
```
2020
KEY<<{delimiter}
@@ -35,40 +35,40 @@ steps:
3535
} >> "$GITHUB_ENV"
3636
```
3737

38-
If an attacker can control the contents of the values assigned to these variables and these are not properly sanitized, they will be able to inject additional variables by injecting new lines or `{delimiters}`.
38+
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}`.
3939

4040
## Recommendations
4141

42-
1. **Do Not Allow Untrusted Data to Influence Environment Variables**:
42+
1. **Do not allow untrusted data to influence environment variables**:
4343

44-
- Avoid using untrusted data sources (e.g., artifact content) to define environment variables.
45-
- Validate and sanitize all inputs before using them in environment settings.
44+
- Avoid using untrusted data sources (e.g., artifact content) to define environment variables.
45+
- Validate and sanitize all inputs before using them in environment settings.
4646

47-
2. **Do Not Allow New Lines When Defining Single Line Environment Variables**:
47+
2. **Do not allow new lines when defining single line environment variables**:
4848

49-
- `echo "BODY=$(echo "$BODY" | tr -d '\n')" >> "$GITHUB_ENV"`
49+
- `echo "BODY=$(echo "$BODY" | tr -d '\n')" >> "$GITHUB_ENV"`
5050

51-
3. **Use Unique Identifiers When Defining Multi Line Environment Variables**:
51+
3. **Use unique identifiers when defining multi line environment variables**:
5252

53-
```bash
54-
steps:
55-
- name: Set the value in bash
56-
id: step_one
57-
run: |
58-
# Generate a UUID
59-
UUID=$(uuidgen)
60-
{
61-
echo "JSON_RESPONSE<<EOF$UUID"
62-
curl https://example.com
63-
echo "EOF$UUID"
64-
} >> "$GITHUB_ENV"
65-
```
53+
```bash
54+
steps:
55+
- name: Set the value in bash
56+
id: step_one
57+
run: |
58+
# Generate a UUID
59+
UUID=$(uuidgen)
60+
{
61+
echo "JSON_RESPONSE<<EOF$UUID"
62+
curl https://example.com
63+
echo "EOF$UUID"
64+
} >> "$GITHUB_ENV"
65+
```
6666

6767
## Examples
6868

6969
### Example of Vulnerability
7070

71-
Consider the following basic setup where an environment variable `MYVAR` is set and used in different steps:
71+
Consider the following basic setup where an environment variable `MYVAR` is set and used in subsequent steps:
7272

7373
```yaml
7474
steps:
@@ -78,17 +78,17 @@ steps:
7878
BODY: ${{ github.event.comment.body }}
7979
run: |
8080
REPLACED=$(echo "$BODY" | sed 's/FOO/BAR/g')
81-
echo "BODY=$REPLACED" >> "$GITHUB_ENV"
81+
echo "MYVAR=$REPLACED" >> "$GITHUB_ENV"
8282
```
8383

84-
If an attacker can manipulate the value being set, such as through artifact downloads or user inputs, they can potentially inject new Environment variables. For example, they could write an Issue comment like:
84+
If an attacker can manipulate the value being set, such as through artifact downloads or user inputs, the attacker can potentially inject new environment variables. For example, they could write an issue comment like:
8585

86-
```
86+
```text
8787
FOO
8888
NEW_ENV_VAR=MALICIOUS_VALUE
8989
```
9090

91-
Likewise, if the attacker controls a file in the Runner's workspace (eg: the workflow checkouts untrusted code or downloads an untrusted artifact), and the contents of that file are assigned to an environment variable such as:
91+
Likewise, if the attacker controls a file in the GitHub Actions Runner's workspace (eg: the workflow checkouts untrusted code or downloads an untrusted artifact) and the contents of that file are assigned to an environment variable such as:
9292
9393
```bash
9494
- run: |
@@ -109,7 +109,7 @@ An attacker could craft a malicious artifact that writes dangerous environment v
109109
110110
### Exploitation
111111
112-
An attacker will be able to run arbitrary code by injecting environment variables such as `LD_PRELOAD`, `BASH_ENV`, etc.
112+
An attacker is be able to run arbitrary code by injecting environment variables such as `LD_PRELOAD`, `BASH_ENV`, etc.
113113
114114
## References
115115

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

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
## Description
44

5-
GitHub Actions allow to define Environment Variables by writing to a file pointed to by the `GITHUB_ENV` environment variable:
5+
GitHub Actions allow to define environment variables by writing to a file pointed to by the `GITHUB_ENV` environment variable:
66

7-
This file should lines in the `KEY=VALUE` format:
7+
This file contains lines in the `KEY=VALUE` format:
88

99
```bash
1010
steps:
@@ -14,7 +14,7 @@ steps:
1414
echo "action_state=yellow" >> "$GITHUB_ENV"
1515
```
1616

17-
It is also possible to define a multiline variables by using the following format:
17+
It is also possible to define multiline variables by using the [following construct](https://en.wikipedia.org/wiki/Here_document):
1818

1919
```
2020
KEY<<{delimiter}
@@ -35,40 +35,40 @@ steps:
3535
} >> "$GITHUB_ENV"
3636
```
3737

38-
If an attacker can control the contents of the values assigned to these variables and these are not properly sanitized, they will be able to inject additional variables by injecting new lines or `{delimiters}`.
38+
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}`.
3939

4040
## Recommendations
4141

42-
1. **Do Not Allow Untrusted Data to Influence Environment Variables**:
42+
1. **Do not allow untrusted data to influence environment variables**:
4343

44-
- Avoid using untrusted data sources (e.g., artifact content) to define environment variables.
45-
- Validate and sanitize all inputs before using them in environment settings.
44+
- Avoid using untrusted data sources (e.g., artifact content) to define environment variables.
45+
- Validate and sanitize all inputs before using them in environment settings.
4646

47-
2. **Do Not Allow New Lines When Defining Single Line Environment Variables**:
47+
2. **Do not allow new lines when defining single line environment variables**:
4848

49-
- `echo "BODY=$(echo "$BODY" | tr -d '\n')" >> "$GITHUB_ENV"`
49+
- `echo "BODY=$(echo "$BODY" | tr -d '\n')" >> "$GITHUB_ENV"`
5050

51-
3. **Use Unique Identifiers When Defining Multi Line Environment Variables**:
51+
3. **Use unique identifiers when defining multi line environment variables**:
5252

53-
```bash
54-
steps:
55-
- name: Set the value in bash
56-
id: step_one
57-
run: |
58-
# Generate a UUID
59-
UUID=$(uuidgen)
60-
{
61-
echo "JSON_RESPONSE<<EOF$UUID"
62-
curl https://example.com
63-
echo "EOF$UUID"
64-
} >> "$GITHUB_ENV"
65-
```
53+
```bash
54+
steps:
55+
- name: Set the value in bash
56+
id: step_one
57+
run: |
58+
# Generate a UUID
59+
UUID=$(uuidgen)
60+
{
61+
echo "JSON_RESPONSE<<EOF$UUID"
62+
curl https://example.com
63+
echo "EOF$UUID"
64+
} >> "$GITHUB_ENV"
65+
```
6666

6767
## Examples
6868

6969
### Example of Vulnerability
7070

71-
Consider the following basic setup where an environment variable `MYVAR` is set and used in different steps:
71+
Consider the following basic setup where an environment variable `MYVAR` is set and used in subsequent steps:
7272

7373
```yaml
7474
steps:
@@ -78,17 +78,17 @@ steps:
7878
BODY: ${{ github.event.comment.body }}
7979
run: |
8080
REPLACED=$(echo "$BODY" | sed 's/FOO/BAR/g')
81-
echo "BODY=$REPLACED" >> "$GITHUB_ENV"
81+
echo "MYVAR=$REPLACED" >> "$GITHUB_ENV"
8282
```
8383

84-
If an attacker can manipulate the value being set, such as through artifact downloads or user inputs, they can potentially inject new Environment variables. For example, they could write an Issue comment like:
84+
If an attacker can manipulate the value being set, such as through artifact downloads or user inputs, the attacker can potentially inject new environment variables. For example, they could write an issue comment like:
8585

86-
```
86+
```text
8787
FOO
8888
NEW_ENV_VAR=MALICIOUS_VALUE
8989
```
9090

91-
Likewise, if the attacker controls a file in the Runner's workspace (eg: the workflow checkouts untrusted code or downloads an untrusted artifact), and the contents of that file are assigned to an environment variable such as:
91+
Likewise, if the attacker controls a file in the GitHub Actions Runner's workspace (eg: the workflow checkouts untrusted code or downloads an untrusted artifact) and the contents of that file are assigned to an environment variable such as:
9292
9393
```bash
9494
- run: |
@@ -109,7 +109,7 @@ An attacker could craft a malicious artifact that writes dangerous environment v
109109
110110
### Exploitation
111111
112-
An attacker will be able to run arbitrary code by injecting environment variables such as `LD_PRELOAD`, `BASH_ENV`, etc.
112+
An attacker is be able to run arbitrary code by injecting environment variables such as `LD_PRELOAD`, `BASH_ENV`, etc.
113113
114114
## References
115115

0 commit comments

Comments
 (0)