Skip to content

Commit 9fba7d3

Browse files
committed
Improve documentation
1 parent 40b7910 commit 9fba7d3

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

javascript/ql/src/Security/CWE-094/ExpressionInjection.qhelp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
The best practice to avoid code injection vulnerabilities
2222
in GitHub workflows is to set the untrusted input value of the expression
2323
to an intermediate environment variable and then use the environment variable
24-
using the native syntax of the shell/script interpreter (i.e. <b>NOT</b> the ${{ env.VAR }}).
24+
using the native syntax of the shell/script interpreter (i.e. <b>NOT</b> the <i>${{ env.VAR }}</i>).
2525
</p>
2626
<p>
2727
It is also recommended to limit the permissions of any tokens used
@@ -40,6 +40,18 @@
4040
the environment variable and will prevent the attack:
4141
</p>
4242
<sample src="examples/comment_issue_good.yml" />
43+
44+
<p>
45+
The following example uses an environment variable, but
46+
still allows injection because of the use of expression syntax:
47+
</p>
48+
<sample src="examples/comment_issue_bad_env.yml" />
49+
50+
<p>
51+
The following example uses shell syntax to read
52+
the environment variable and will prevent the attack:
53+
</p>
54+
<sample src="examples/comment_issue_good.yml" />
4355
</example>
4456

4557
<references>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
on: issue_comment
2+
3+
jobs:
4+
echo-body:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- env:
8+
BODY: ${{ github.event.issue.body }}
9+
run: |
10+
echo '${{ env.BODY }}'

0 commit comments

Comments
 (0)