Skip to content

Commit 06747cd

Browse files
author
Alvaro Muñoz
committed
Add tests for untrusted checkouts in workflow_run triggered workflows
1 parent 0a2be55 commit 06747cd

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

ql/lib/codeql/actions/dataflow/FlowSources.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ private predicate isExternalUserControlledWorkflowRun(string context) {
106106
[
107107
"github\\.event\\.workflow\\.path", "github\\.event\\.workflow_run\\.head_branch",
108108
"github\\.event\\.workflow_run\\.display_title",
109+
"github\\.event\\.workflow_run\\.head_branch",
109110
"github\\.event\\.workflow_run\\.head_repository\\.description",
111+
"github\\.event\\.workflow_run\\.head_repository\\.full_name",
112+
"github\\.event\\.workflow_run\\.head_repository\\.name",
110113
"github\\.event\\.workflow_run\\.head_commit\\.message",
111114
"github\\.event\\.workflow_run\\.head_commit\\.author\\.email",
112115
"github\\.event\\.workflow_run\\.head_commit\\.author\\.name",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
on:
2+
workflow_run:
3+
workflows: ['Test']
4+
types: [completed]
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
if: github.event.workflow_run.conclusion == "success"
10+
env:
11+
HEAD: ${{ github.event.workflow_run.head.sha }}
12+
steps:
13+
- uses: actions/checkout@v2
14+
with:
15+
ref: ${{ github.event.workflow_run.head.sha }}
16+
- uses: actions/checkout@v2
17+
with:
18+
ref: ${{ env.HEAD }}
19+

ql/test/query-tests/Security/CWE-829/UntrustedCheckout.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@
2020
| .github/workflows/issue_comment_octokit.yml:109:9:114:66 | Uses Step | Potential unsafe checkout of untrusted pull request on privileged workflow. |
2121
| .github/workflows/untrusted_checkout.yml:10:9:13:6 | Uses Step | Potential unsafe checkout of untrusted pull request on privileged workflow. |
2222
| .github/workflows/untrusted_checkout.yml:13:9:15:31 | Uses Step | Potential unsafe checkout of untrusted pull request on privileged workflow. |
23+
| .github/workflows/workflow_run_untrusted_checkout.yml:13:9:16:6 | Uses Step | Potential unsafe checkout of untrusted pull request on privileged workflow. |
24+
| .github/workflows/workflow_run_untrusted_checkout.yml:16:9:18:31 | Uses Step | Potential unsafe checkout of untrusted pull request on privileged workflow. |

0 commit comments

Comments
 (0)