GitHub Actions の checkout における pull_request_target イベントのデフォルト設定をより安全に
GitHub は、フォークからのプルリクエストを悪用したサプライチェーン攻撃を防ぐため、GitHub Actions の checkout アクションにデフォルトでセキュリティ強化機能を導入すると発表した。
キーポイント
「pwn request」攻撃の防止策実装
pull_request_target イベントで、フォークからのプルリクエストコードを自動的にチェックアウトしようとする試みを actions/checkout v7 で拒否する機能を実装した。
強制適用とバージョン管理のルール
2026 年 7 月 16 日までに既存の主要バージョンへバックポートされ、フローティングタグ(例:@v4)を使用するワークフローは自動的に更新されるが、特定 SHA やマイナーバージョンを固定している場合は手動アップグレードが必要となる。
適用範囲と制限事項
この対策はフォークからのプルリクエストの HEAD/merge コミットに限定され、他のイベントタイプ(issue_comment など)や git 直接実行による攻撃には対応しないため、完全なセキュリティではない。
例外処理とオプトアウト
同一リポジトリ内のプルリクエストや、信頼できるフォークコードを意図的に使用する必要があるワークフローでは、設定の調整が必要となる可能性がある。
特定のワークフローでの利用理由
カバレッジレポートの生成や認証チェックの実行など、フォークされたプルリクエストコードに高い信頼性が必要なケースのために pull_request_target は存在します。
保護機能のオプトアウト方法と条件
イベントが必要で安全に使用されていることを確認した上で、actions/checkout ステップに allow-unsafe-pr-checkout 入力パラメータを追加することでこの保護を無効化できます。
セキュリティ判断の重要性
保護機能をオプトアウトすることは意図的なセキュリティ上の決定として扱われ、コードレビューや静的解析で容易に識別できるよう意図的に名付けられています。
影響分析・編集コメントを表示
影響分析
本発表は、オープンソースエコシステムにおけるサプライチェーンセキュリティの基準を大幅に引き上げるものであり、悪意のあるフォークからのコード実行によるインシデントを未然に防ぐ重要な一歩です。しかし、完全な解決策ではないため、開発者はワークフローの設計を見直し、git コマンドの利用や他のイベントタイプにおけるリスク管理も継続的に実施する必要があります。
編集コメント
サプライチェーン攻撃が深刻化する中、ツール側のデフォルト設定を「安全側」にシフトするこの変更は、開発者の負担を減らしつつインフラの防御力を底上げする画期的な施策です。ただし、自動化された保護が万能ではないため、セキュリティ意識の高いコードレビュー体制との併用が不可欠です。
pull_request_target イベントは、GitHub Actions において最も誤用されやすいトリガーの一つであり、ワークフローに脆弱性をもたらします。pull_request_target で起動されたワークフローは、ベースリポジトリの GITHUB_TOKEN、シークレット、およびデフォルトブランチキャッシュへのアクセス権限で実行されます。これらのワークフロー内で、フォークからの未レビューなプルリクエストのヘッドをチェックアウトすると、攻撃者が制御するコードがワークフローの完全な特権で実行されてしまう可能性があります。このパターンは「pwn request」と呼ばれ、エコシステム全体で複数のサプライチェーンインシデントの根本原因となってきました。詳細については、これらの要求を防ぐための当社のブログ記事をご覧ください。
本日より、actions/checkout v7 が一般提供され、デフォルトで一般的な pwn request パターンを拒否するようになります。
2026 年 7 月 16 日までに、この強制措置は現在サポートされているすべての主要バージョンにバックポートされます。浮動の主要タグ(例:actions/checkout@v4)に固定されたワークフローは、自動的にこの変更を適用します。特定の SHA、マイナーバージョン、またはパッチバージョンに固定されたワークフローはバックポートの影響を受けず、Dependabot を使用するか、確立されたアップグレードプロセスを通じてアップグレードする必要があります。
同じリポジトリ内のプルリクエストには影響がなく、pull_request イベントも変更されません。
何が変わるか
actions/checkout v7 は、pull_request_target および workflow_run ワークフロー(後者は workflow_run.event が pull_request* イベントの場合のみ)において、フォークからのプルリクエストコードのフェッチを拒否します。これは、プルリクエストがフォークからのものであり、かつ以下のいずれかが当てはまる場合に発生します。
repository: フォークプルリクエストのリポジトリに解決されます。
ref: refs/pull//head または refs/pull//merge に一致します。
ref: フォークプルリクエストの head または merge コミットの SHA に解決されます。
この変更は、Actions エコシステムにおける最も一般的な pwn リクエスト(悪意のあるコード実行要求)を防ぐことに焦点を当てています。これにより、actions/checkout は、以下のような不十分な入力を持つフォークからの pull_request_target イベントで使用された場合に失敗するようになります。
ref: refs/pull/${{ github.event.pull_request.number }}/merge
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
変更されない、または対象外となる事項
pwn リクエストは、この変更の範囲外の他の方法でも導入される可能性があります。例えば、run ブロックで git や gh CLI を使用して、HEAD リファレンスやその他の信頼できないソースからプルし、その後実行するケースが該当します。また、pull_request_target 以外のイベントタイプ(issue_comment など)でトリガーされた pwn リクエストは、この変更ではブロックされません。追加のイベントに対するさらなる強化については、今後のリリースで検討される可能性があります。
この変更は、フォークされたプルリクエストのヘッドおよびマージコミットのチェックアウトのみをブロックします。他の信頼できないリポジトリからのチェックアウトはブロックされません。例えば、repository 引数に無関係なサードパーティ製のリポジトリを設定してもブロックされることはありません。特権イベント内で信頼できないコードをチェックアウトして実行することは依然として「pwn リクエスト」のリスクであり、レビューが必要 remains です。
この保護機能からのオプトアウト
一部のワークフローでは、フォークされたプルリクエストのコードを高い信頼性でチェックアウトする必要があり、これが pull_request_target が最初に作成された理由です。例えば、プライベートなアーティファクトレジストリを必要とするカバレッジレポートの生成や、プルリクエストから導入された変更に対して認証済みチェックを実行・実行するケースなどが該当します。これらのワークフローが引き続き機能できるようにオプトアウト機能を維持していますが、オプトアウトは意図的なセキュリティ上の判断として扱うべきです。
オプトアウトを行う前に、pull_request_target を安全に使用するためのガイダンスをお読みください。イベントが必要であり、ワークフロー内で安全に使用されることを確認した後、actions/checkout ステップに allow-unsafe-pr-checkout 入力パラメータを追加することで、この保護機能からのオプトアウトが可能です。このフラグはコードレビューや静的解析で容易に目立つように意図的に命名されています。
詳細の参照とフィードバックの提供
詳細については、actions/checkout リポジトリ、pull_request_target に関する GitHub Actions のドキュメント、および GitHub Actions 向けのセキュリティ強化ガイダンスをご覧ください。
The post Safer pull_request_target defaults for GitHub Actions checkout appeared first on The GitHub Blog.
GitHub Actions の checkout アクションにおける pull_request_target デフォルトの安全性向上に関する記事は、最初に The GitHub Blog で公開されました。
原文を表示
The pull_request_target event is one of the most commonly misused triggers in GitHub Actions, leading to vulnerabilities in workflows. Workflows triggered by pull_request_target run with the base repository’s GITHUB_TOKEN, secrets, and default-branch cache access. Checking out the head of an unreviewed pull request from a fork inside one of these workflows typically lets attacker-controlled code execute with the workflow’s full privileges. This pattern is known as a “pwn request,” and it has been the root cause of multiple supply-chain incidents across the ecosystem. For more information, see our blog posts about helping to prevent these requests.
Starting today, actions/checkout v7 is generally available and refuses common pwn request patterns by default.
On July 16, 2026, we’ll backport the enforcement to all currently supported major versions. Workflows pinned to a floating major tag (e.g., actions/checkout@v4) will automatically pick up the change. Workflows pinned to a specific SHA, minor, or patch version aren’t affected by the backport and will need to upgrade using Dependabot or through established upgrade processes.
Same-repository pull requests aren’t affected, and the pull_request event is unchanged.
What’s changing
actions/checkout v7 refuses to fetch fork pull request code in pull_request_target and workflow_run workflows (the latter only when workflow_run.event is a pull_request* event). It refuses when the pull request is from a fork and any of the following apply:
repository: resolves to the fork pull request’s repository.
ref: matches refs/pull//head or refs/pull//merge.
ref: resolves to a fork pull request’s head or merge commit SHA.
This change is focused on preventing the most common form of pwn requests in the Actions ecosystem. actions/checkout will now fail for usage in pull_request_target events from forks with insecure inputs such as:
ref: refs/pull/${{ github.event.pull_request.number }}/merge
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
What’s not changing or covered
Pwn requests can be introduced in other ways outside of the scope of this change. For example, a run block uses git or the gh CLI to pull a HEAD ref or other untrusted source that is subsequently executed. Additionally, pwn requests triggered in other event types besides pull_request_target (such as issue_comment) will not be blocked by this change. Further hardening of additional events may be explored in future releases.
This change only blocks checkouts of the fork pull request head and merge commits. It does not block checkouts of other untrusted repositories. For example, setting repository: to an unrelated third-party repository is not blocked. Checking out and executing any untrusted code in a privileged event remains a pwn request risk that should be reviewed.
Opting out of this protection
Some workflows need to check out fork pull request code with elevated trust, and this is why pull_request_target was created in the first place. For example, generating coverage reports that require a private artifact registry or producing and running authenticated checks against the changes introduced from the pull request. We’re keeping an opt-out available so these workflows can continue to function, but you should treat opting out as a deliberate security decision.
Before you opt out, read our guidance for securely using pull_request_target. After confirming the event is needed and safely used in your workflow, you can opt out of this protection by adding the allow-unsafe-pr-checkout input on the actions/checkout step. The flag is intentionally named to be easy to spot in code review and static analysis.
Read more and give your feedback
For more details, see the actions/checkout repository, the GitHub Actions documentation on pull_request_target, and the security hardening guidance for GitHub Actions.
The post Safer pull_request_target defaults for GitHub Actions checkout appeared first on The GitHub Blog.
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み