Skip to content

Commit 44377ac

Browse files
author
Alvaro Muñoz
committed
Improve Cache Poisoning quer
1 parent 2d09d1e commit 44377ac

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

ql/src/Security/CWE-349/CachePoisoning.ql

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ import codeql.actions.security.UntrustedCheckoutQuery
1616
import codeql.actions.security.CachePoisoningQuery
1717
import codeql.actions.security.PoisonableSteps
1818

19-
from LocalJob j, PRHeadCheckoutStep checkout
19+
from LocalJob j, PRHeadCheckoutStep checkout, Step s
2020
where
21+
// Excluding privileged workflows since they can be easily exploited in similar circumstances
22+
not j.isPrivileged() and
2123
// The workflow runs in the context of the default branch
2224
// TODO: (require to collect trigger types)
2325
// - add push to default branch?
@@ -37,10 +39,13 @@ where
3739
(
3840
// The job writes to the cache
3941
// (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
4144
or
4245
// The job executes checked-out code
4346
// (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
4549
)
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

Comments
 (0)