File tree Expand file tree Collapse file tree
javascript/ql/src/Security/CWE-094 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
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 >
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