@@ -142,23 +142,45 @@ predicate isScriptInjectable(Actions::GitHubScript script, string injection, str
142142 )
143143}
144144
145+ /**
146+ * Holds if the composite action contains untrusted expression interpolation `${{ e }}`.
147+ */
148+ YamlNode getInjectableCompositeActionNode ( Actions:: Runs runs , string injection , string context ) {
149+ exists ( Actions:: Run run |
150+ isRunInjectable ( run , injection , context ) and
151+ result = run and
152+ run .getStep ( ) .getRuns ( ) = runs
153+ )
154+ or
155+ exists ( Actions:: GitHubScript script |
156+ isScriptInjectable ( script , injection , context ) and
157+ result = script and
158+ script .getWith ( ) .getStep ( ) .getRuns ( ) = runs
159+ )
160+ }
161+
162+ /**
163+ * Holds if the workflow contains untrusted expression interpolation `${{ e }}`.
164+ */
165+ YamlNode getInjectableWorkflowNode ( Actions:: On on , string injection , string context ) {
166+ exists ( Actions:: Run run |
167+ isRunInjectable ( run , injection , context ) and
168+ result = run and
169+ run .getStep ( ) .getJob ( ) .getWorkflow ( ) .getOn ( ) = on
170+ )
171+ or
172+ exists ( Actions:: GitHubScript script |
173+ isScriptInjectable ( script , injection , context ) and
174+ result = script and
175+ script .getWith ( ) .getStep ( ) .getJob ( ) .getWorkflow ( ) .getOn ( ) = on
176+ )
177+ }
178+
145179from YamlNode node , string injection , string context
146180where
147181 exists ( Actions:: CompositeAction action , Actions:: Runs runs |
148182 action .getRuns ( ) = runs and
149- (
150- exists ( Actions:: Run run |
151- isRunInjectable ( run , injection , context ) and
152- node = run and
153- run .getStep ( ) .getRuns ( ) = runs
154- )
155- or
156- exists ( Actions:: GitHubScript script |
157- node = script and
158- script .getWith ( ) .getStep ( ) .getRuns ( ) = runs and
159- isScriptInjectable ( script , injection , context )
160- )
161- ) and
183+ node = getInjectableCompositeActionNode ( runs , injection , context ) and
162184 (
163185 isExternalUserControlledIssue ( context ) or
164186 isExternalUserControlledPullRequest ( context ) or
@@ -172,19 +194,7 @@ where
172194 )
173195 or
174196 exists ( Actions:: On on |
175- (
176- exists ( Actions:: Run run |
177- isRunInjectable ( run , injection , context ) and
178- node = run and
179- run .getStep ( ) .getJob ( ) .getWorkflow ( ) .getOn ( ) = on
180- )
181- or
182- exists ( Actions:: GitHubScript script |
183- node = script and
184- script .getWith ( ) .getStep ( ) .getJob ( ) .getWorkflow ( ) .getOn ( ) = on and
185- isScriptInjectable ( script , injection , context )
186- )
187- ) and
197+ node = getInjectableWorkflowNode ( on , injection , context ) and
188198 (
189199 exists ( on .getNode ( "issues" ) ) and
190200 isExternalUserControlledIssue ( context )
0 commit comments