@@ -3,20 +3,11 @@ private import codeql.actions.TaintTracking
33private import codeql.actions.dataflow.ExternalFlow
44private import codeql.actions.security.ArtifactPoisoningQuery
55private import codeql.actions.security.UntrustedCheckoutQuery
6- private import codeql.actions.dataflow.FlowSteps
7- import codeql.actions.DataFlow
8- import codeql.actions.dataflow.FlowSources
96
107abstract class EnvPathInjectionSink extends DataFlow:: Node { }
118
129/**
1310 * Holds if a Run step declares a PATH environment variable with contents from a local file.
14- * e.g.
15- * run: |
16- * cat foo.txt >> $GITHUB_PATH
17- * echo "$(cat foo.txt)" >> $GITHUB_PATH
18- * FOO=$(cat foo.txt)
19- * echo "$FOO" >> $GITHUB_PATH
2011 */
2112class EnvPathInjectionFromFileReadSink extends EnvPathInjectionSink {
2213 EnvPathInjectionFromFileReadSink ( ) {
@@ -28,11 +19,15 @@ class EnvPathInjectionFromFileReadSink extends EnvPathInjectionSink {
2819 this .asExpr ( ) = run .getScript ( ) and
2920 step .getAFollowingStep ( ) = run and
3021 (
22+ // echo "$(cat foo.txt)" >> $GITHUB_PATH
23+ // FOO=$(cat foo.txt)
24+ // echo "$FOO" >> $GITHUB_PATH
3125 exists ( string cmd |
32- run .getScript ( ) .getACmdReachingGitHubPathWrite ( cmd ) and
33- run .getScript ( ) .getAFileReadCommand ( ) = cmd
26+ run .getScript ( ) .getAFileReadCommand ( ) = cmd and
27+ run .getScript ( ) .getACmdReachingGitHubPathWrite ( cmd )
3428 )
3529 or
30+ // cat foo.txt >> $GITHUB_PATH
3631 run .getScript ( ) .fileToGitHubPath ( _)
3732 )
3833 )
@@ -91,8 +86,10 @@ private module EnvPathInjectionConfig implements DataFlow::ConfigSig {
9186 run .getInScopeEnvVarExpr ( var ) = pred .asExpr ( ) and
9287 succ .asExpr ( ) = run .getScript ( ) and
9388 (
94- run .getScript ( ) .getAnEnvReachingGitHubOutputWrite ( var , _) or
95- run .getScript ( ) .getAnEnvReachingGitHubEnvWrite ( var , _) or
89+ run .getScript ( ) .getAnEnvReachingGitHubEnvWrite ( var , _)
90+ or
91+ run .getScript ( ) .getAnEnvReachingGitHubOutputWrite ( var , _)
92+ or
9693 run .getScript ( ) .getAnEnvReachingGitHubPathWrite ( var )
9794 )
9895 )
0 commit comments