@@ -18,20 +18,30 @@ import codeql.actions.security.CachePoisoningQuery
1818import codeql.actions.security.PoisonableSteps
1919import codeql.actions.security.ControlChecks
2020
21- query predicate edges ( Step a , Step b ) { a .getNextStep ( ) = b }
21+ query predicate edges ( AstNode predecessor , AstNode successor ) {
22+ predecessor .( Step ) .getNextStep ( ) = successor
23+ or
24+ checkoutReferenceEdge ( predecessor , successor )
25+ }
2226
23- from LocalJob job , Event event , Step source , Step step , string message , string path
27+ from
28+ LocalJob job , Event event , Step source , Step step , string message , string path ,
29+ AstNode untrustedInput , string untrustedInputText
2430where
2531 // the job checkouts untrusted code from a pull request or downloads an untrusted artifact
2632 job .getAStep ( ) = source and
2733 (
2834 source instanceof PRHeadCheckoutStep and
29- message = "due to privilege checkout of untrusted code." and
30- path = source .( PRHeadCheckoutStep ) .getPath ( )
35+ message = "due to privilege checkout of untrusted code from" and
36+ path = source .( PRHeadCheckoutStep ) .getPath ( ) and
37+ untrustedInput = getCheckoutReference ( source ) and
38+ untrustedInputText = getCheckoutReferenceText ( untrustedInput )
3139 or
3240 source instanceof UntrustedArtifactDownloadStep and
33- message = "due to downloading an untrusted artifact." and
34- path = source .( UntrustedArtifactDownloadStep ) .getPath ( )
41+ message = "due to downloading" and
42+ path = source .( UntrustedArtifactDownloadStep ) .getPath ( ) and
43+ untrustedInput = source and
44+ untrustedInputText = "an untrusted artifact"
3545 ) and
3646 // the checkout/download is not controlled by an access check
3747 not exists ( ControlCheck check |
5767 step instanceof PoisonableStep and
5868 // excluding privileged workflows since they can be exploited in easier circumstances
5969 not job .isPrivileged ( )
60- select step , source , step ,
61- "Potential cache poisoning in the context of the default branch " + message + " ($@)." , event ,
62- event .getName ( )
70+ select step , untrustedInput , step ,
71+ "Potential cache poisoning in the context of the default branch " + message + " $@. ($@)." ,
72+ untrustedInput , untrustedInputText , event , event .getName ( )
0 commit comments