File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed
javascript/ql/src/Security/CWE-094 Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 21
21
The best practice to avoid code injection vulnerabilities
22
22
in GitHub workflows is to set the untrusted input value of the expression
23
23
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 > ).
25
25
</p >
26
26
<p >
27
27
It is also recommended to limit the permissions of any tokens used
40
40
the environment variable and will prevent the attack:
41
41
</p >
42
42
<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" />
43
55
</example >
44
56
45
57
<references >
Original file line number Diff line number Diff line change
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 }}'
You can’t perform that action at this time.
0 commit comments