GitHub Actions の checkout における pull_request_target イベントのデフォルト設定をより安全に
本文の状態
日本語全文を表示中
詳細モードで約5分の本文を読めます。
同じ出来事の情報源
この情報源を基点に整理
GitHub Changelog
GitHub が、フォークされたプルリクエストから未レビューのコードをチェックアウトする際に権限が不正に利用される「pwn request」と呼ばれる脆弱性に対処するため、pull_request_target イベントの checkout デフォルト設定を強化した。
Source Article
元記事を日本語で読む
本文に関係しない購読案内、埋め込み通知、サイト内プロモーションは除いています。
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デイリーブリーフで今日の重要ニュースをまとめ読み