Skip to content

Commit 4b74ade

Browse files
author
Alvaro Muñoz
committed
Account for branches filter as a way to prevent workflow_run to trigger on PRs from forks
1 parent ef37e3c commit 4b74ade

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

ql/lib/codeql/actions/ast/internal/Ast.qll

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -722,13 +722,10 @@ class EventImpl extends AstNodeImpl, TEventNode {
722722
not this.getName() = "workflow_run"
723723
or
724724
this.getName() = "workflow_run" and
725-
// workflow_run cannot be externally triggered if they triggering workflow runs in the context of the default branch
726-
// since an attacker can change the triggering workflow from any event to `pull_request` to trigger the workflow
727-
// but in that case, the triggering workflow will run in the context of the PR head branch
728-
(
729-
not exists(this.getAPropertyValue("branches")) or
730-
this.getAPropertyValue("branches").matches("%*%")
731-
)
725+
// workflow_run cannot be externally triggered if the triggering workflow runs in the context of the default branch
726+
// An attacker can change the triggering workflow from any event to `pull_request` to trigger the workflow
727+
// in that case, the triggering workflow will run in the context of the PR head branch
728+
not exists(this.getAPropertyValue("branches"))
732729
or
733730
// the event is `workflow_call` and there is a caller workflow that can be triggered externally
734731
this.getName() = "workflow_call" and

ql/lib/ext/config/argument_injection_sinks.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ extensions:
33
pack: github/actions-all
44
extensible: argumentInjectionSinksDataModel
55
# https://gtfobins.github.io/
6+
# https://0xn3va.gitbook.io/cheat-sheets/web-application/command-injection/argument-injection
67
data:
78
- ["(awk)(.*?)", 2, 3]
9+
- ["(curl)(.*?)", 2, 3]
10+
- ["(find)(.*?)", 2, 3]
11+
- ["(git)(.*?)", 2, 3]
812
- ["(sed)(.*?)", 2, 3]
13+
- ["(tar)(.*?)", 2, 3]
14+
- ["(wget)(.*?)", 2, 3]
15+
- ["(zip)(.*?)", 2, 3]
916

0 commit comments

Comments
 (0)