Skip to content

ci: bump actions/checkout to v7 and add allow-unsafe-pr-checkout flag - #30460

Merged
chirag-madlani merged 1 commit into
mainfrom
ci/actions-checkout-v7-fork-flag
Jul 24, 2026
Merged

chirag-madlani merged 1 commit into
mainfrom
ci/actions-checkout-v7-fork-flag

Conversation

@chirag-madlani

@chirag-madlani chirag-madlani commented Jul 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fork PRs against every `pull_request_target` workflow have been failing with:

```
Error: Refusing to check out fork pull request code from a 'pull_request_target' workflow.
... set 'allow-unsafe-pr-checkout: true' on the actions/checkout step.
```

This is the safe-defaults behaviour introduced in `actions/[email protected]` and backported to `v5.1.0` / `v6.1.0` — see GitHub Changelog: Safer pull_request_target defaults for GitHub Actions checkout. Every fork checkout under `pull_request_target` must now opt in explicitly.

The old (pre-#30310) workflows had this opt-in already; the rewrite dropped it in the process of bumping actions versions.

Change

Two-part fix across all 19 workflows that check out fork PR code under `pull_request_target`:

  1. Bump `actions/checkout@v5` (and remaining `@v4`) to `@v7`. Devops asked for currency, and v7.0.1 also refines the check to skip when `ref:` is unspecified — helpful for future workflows that use the default checkout.

  2. Add `allow-unsafe-pr-checkout: true` on every checkout step that fetches `github.event.pull_request.head.sha` under `pull_request_target`. Checkouts that use `github.sha` (base branch tip) or the default ref remain untouched — those don't run fork code.

Files touched (19)

Category Files
Playwright `playwright-mysql-e2e.yml`, `playwright-integration-tests-mysql.yml`, `playwright-integration-tests-postgres.yml`, `playwright-sso-tests.yml`
Integration tests `integration-tests-mysql-elasticsearch.yml`, `integration-tests-postgres-elasticsearch-redis.yml`, `integration-tests-postgres-opensearch.yml`, `airflow-apis-tests.yml`
Checkstyle `java-checkstyle.yml`, `py-checkstyle.yml`, `ui-checkstyle.yml`
Python tests `py-tests.yml`, `py-tests-postgres.yml`, `py-operator-build-test.yml`
Build `maven-build-collate.yml`, `maven-sonar-build.yml`, `yarn-coverage.yml`
Codegen `typescript-type-generation.yml`, `validate-jsons-yamls.yml`

19 files, +48 / −25 lines. Purely mechanical — no logic, trigger, or test changes.

Security posture unchanged

The pwn-request risk the opt-in flag warns about is mitigated the same way it was pre-#30310:

  • `pull_request_target` runs the base branch's workflow YAML — fork edits to workflow files are ignored.
  • Test/build steps consume the fork tree inside docker containers or sandboxed compilers (mvn, yarn, python venv), not directly in the workflow runner shell — so a malicious fork can't exfiltrate `GITHUB_TOKEN` or connector secrets.
  • Workflows that require executing fork-controlled JS/scripts directly (e.g., `github-script` running a PR-supplied `.cjs`) are separately responsible for using `base.sha` instead of `head.sha`. ci(playwright): restore fork PR support by re-adding pull_request_target #30453 handles that for playwright-summary.

Not in scope

Test plan

  • Every workflow above compiles / runs on a merge_group commit as before (no behavioural change on internal PRs).
  • A fork PR with `safe to test` applied against any of the required-check workflows above (e.g., `java-checkstyle`, `py-checkstyle`, `ui-checkstyle`) is no longer blocked by the `Refusing to check out` error.

🤖 Generated with Claude Code

Greptile Summary

This PR updates checkout usage for fork-testing workflows.

  • Upgrades actions/checkout references to v7 across 19 GitHub Actions workflows.
  • Explicitly enables pull_request_target checkout of pull-request head SHAs.
  • Leaves trusted base-SHA and default-ref checkouts without the unsafe opt-in.

Confidence Score: 2/5

This PR is not safe to merge until fork-controlled execution is isolated from external-service credentials and write-capable repository tokens.

Approved fork runs execute attacker-controlled build or test code in jobs that inject sensitive service credentials or a GitHub token capable of modifying check runs.

.github/workflows/playwright-mysql-e2e.yml, .github/workflows/playwright-sso-tests.yml, .github/workflows/playwright-integration-tests-mysql.yml, .github/workflows/playwright-integration-tests-postgres.yml, .github/workflows/maven-sonar-build.yml

Security Review

The unsafe opt-in restores fork test execution, but affected jobs execute fork-controlled build or test code with external-service credentials or a write-capable GitHub token, enabling credential exfiltration and unauthorized check-run modification after a fork run is approved.

Important Files Changed

Filename Overview
.github/workflows/playwright-mysql-e2e.yml Enables fork-head checkout before PR-controlled tests receive a broad set of database and cloud credentials.
.github/workflows/playwright-sso-tests.yml Enables fork-head checkout before PR-controlled Playwright tests receive SSO account credentials.
.github/workflows/playwright-integration-tests-mysql.yml Enables fork-controlled integration-test execution in a job supplying external database credentials.
.github/workflows/playwright-integration-tests-postgres.yml Mirrors the MySQL integration workflow's unsafe checkout and credential-exposure path.
.github/workflows/maven-sonar-build.yml Enables fork-controlled Maven configuration to execute with a GitHub token carrying check-write permission.
.github/workflows/typescript-type-generation.yml Updates checkout to v7 while retaining the existing explicit unsafe opt-in and fork-specific write restrictions.

Sequence Diagram

sequenceDiagram
  participant Fork as Fork PR
  participant Gate as Safe-to-test gate
  participant Runner as Privileged workflow runner
  participant Code as PR-controlled code
  participant Credentials as Secrets and tokens
  Fork->>Gate: Maintainer-approved test request
  Gate->>Runner: Permit job
  Runner->>Fork: Checkout head SHA
  Runner->>Code: Execute build and test code
  Credentials->>Code: Inject service credentials or token
  Code-->>Fork: Credentials can be exfiltrated
Loading

Reviews (1): Last reviewed commit: "ci: bump actions/checkout to v7 and add ..." | Re-trigger Greptile

Greptile also left 2 inline comments on this PR.

Fork PRs against every pull_request_target workflow have been failing with:

  Error: Refusing to check out fork pull request code from a
  'pull_request_target' workflow. ... set 'allow-unsafe-pr-checkout: true'
  on the actions/checkout step.

This is the safe-defaults behaviour introduced in actions/checkout v7.0.0
and backported to v5.1.0 / v6.1.0
(https://github.blog/changelog/2026-06-18-safer-pull_request_target-defaults-for-github-actions-checkout/).
Every fork checkout under pull_request_target must now opt in explicitly.

Two-part fix across all 19 workflows that check out fork PR code under
pull_request_target:

  1. Bump `actions/checkout@v5` (and remaining `@v4`) to `@v7`. Devops
     asked for currency, and v7.0.1 also refines the check to skip when
     `ref:` is unspecified — helpful for any future workflow that uses
     the default checkout.

  2. Add `allow-unsafe-pr-checkout: true` on every checkout step that
     fetches `github.event.pull_request.head.sha` under pull_request_target.
     Checkouts that use `github.sha` (base branch tip) or the default
     ref remain untouched — those don't run fork code.

The pwn-request risk the opt-in flag warns about is mitigated for these
workflows the same way it was pre-#30310:
  - pull_request_target continues to run the BASE branch's workflow YAML
    (fork edits to workflow files are ignored)
  - Test/build steps consume the fork tree inside docker containers or
    sandboxed compilers (mvn, yarn, python venv), not directly in the
    workflow runner shell
  - Workflows that require executing fork-controlled JS/scripts directly
    (e.g., github-script running a PR-supplied .cjs) are separately
    responsible for using base.sha, not head.sha (see #30453 for the
    playwright-summary case)

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 24, 2026 10:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added safe to test Add this label to run secure Github workflows on PRs UI UI specific issues labels Jul 24, 2026
@gitar-bot

gitar-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Bumps actions/checkout to v7 and adds the allow-unsafe-pr-checkout flag across 19 workflows to fix failing fork PR checkouts under pull_request_target. No issues found.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@chirag-madlani
chirag-madlani enabled auto-merge (squash) July 24, 2026 10:26
uses: actions/checkout@v5
uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'merge_group' && github.sha || github.event.pull_request.head.sha }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security Fork tests receive service credentials

When an approved fork PR runs, this checkout loads the fork's build and Playwright code before the job injects database, cloud-provider, and SSO credentials into that code, allowing a malicious test or build hook to exfiltrate those credentials.

uses: actions/checkout@v5
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security Fork build receives writable token

When an approved fork PR runs, this checkout loads its pom.xml and build configuration before Maven executes with GITHUB_TOKEN in the environment; a malicious build plugin can use the job's checks: write permission to exfiltrate the token or modify repository check runs.

@chirag-madlani
chirag-madlani disabled auto-merge July 24, 2026 11:03
@chirag-madlani
chirag-madlani merged commit 5eeda19 into main Jul 24, 2026
88 of 91 checks passed
@chirag-madlani
chirag-madlani deleted the ci/actions-checkout-v7-fork-flag branch July 24, 2026 11:03

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants