@@ -16,8 +16,10 @@ import codeql.actions.security.UntrustedCheckoutQuery
16
16
import codeql.actions.security.CachePoisoningQuery
17
17
import codeql.actions.security.PoisonableSteps
18
18
19
- from LocalJob j , PRHeadCheckoutStep checkout
19
+ from LocalJob j , PRHeadCheckoutStep checkout , Step s
20
20
where
21
+ // Excluding privileged workflows since they can be easily exploited in similar circumstances
22
+ not j .isPrivileged ( ) and
21
23
// The workflow runs in the context of the default branch
22
24
// TODO: (require to collect trigger types)
23
25
// - add push to default branch?
@@ -37,10 +39,13 @@ where
37
39
(
38
40
// The job writes to the cache
39
41
// (No need to follow the checkout step as the cache writing is normally done after the job completes)
40
- j .getAStep ( ) instanceof CacheWritingStep
42
+ j .getAStep ( ) = s and
43
+ s instanceof CacheWritingStep
41
44
or
42
45
// The job executes checked-out code
43
46
// (The cache specific token can be leaked even for non-privileged workflows)
44
- checkout .getAFollowingStep ( ) instanceof PoisonableStep
47
+ checkout .getAFollowingStep ( ) = s and
48
+ s instanceof PoisonableStep
45
49
)
46
- select checkout , "Potential cache poisoning on privileged workflow."
50
+ select checkout , "Untrusted checked-out code may lead to cache poisoning on step $@." , s ,
51
+ s .toString ( )
0 commit comments