Repository navigation
Require explicit opt-in for unrestricted pull_request_target forks - #74884
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. Design Decision Gate 🏗️Outcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Ponytail Reviewer completed successfully!
|
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
Reviewed the changed fork-admission validation. The strict wildcard opt-in and warning behavior are otherwise coherent.
Highlights
- One medium security concern: imported feature maps can implicitly enable the dangerous unrestricted-forks opt-in for a consuming workflow; see the inline comment.
- No other actionable correctness or regression issues found in the changed lines.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~4 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
| } | ||
|
|
||
| if effectiveStrictMode && unrestrictedForks { | ||
| allowUnrestrictedForks := dangerouslyAllowsPullRequestTargetForksAll(workflowData) |
There was a problem hiding this comment.
The strict-mode bypass accepts this dangerous opt-in from workflowData.Features, which is populated by merged imported workflow features, so an imported file can silently enable unrestricted fork admission for a consuming workflow.
💡 Keep the opt-in explicit at the top level
MergeFeatures adds imported flags when the main workflow does not define them, and validation runs after that merge. Consequently, a reusable import containing dangerously-allow-pull-request-target-forks-all: true changes the security policy of a strict consumer without the consumer declaring the opt-in. Restrict this particular bypass to the main workflow's own frontmatter (or reject imported dangerous flags), and add a regression test covering an import-only flag.
There was a problem hiding this comment.
Fixed the bypass by checking this opt-in only in the main workflow's top-level frontmatter, and added an import-only regression test. Commit ac6cd59b.
There was a problem hiding this comment.
What this change does: Strict mode now rejects unrestricted pull_request_target fork admission unless the dangerous opt-in is set. Non-strict mode and the opt-in still emit the wildcard warning, with matching schema, documentation, and regression coverage.
Should fix:
-
Duplicate dangerous-feature lookup (
pkg/workflow/pull_request_target_validation.go:L279)- What this is: The new helper repeats the case-insensitive boolean-frontmatter lookup already implemented by the helper immediately above, differing only in the flag constant.
- Problem: Every new dangerous opt-in now needs another copy, so the shared lookup rules can drift.
- Fix: Replace both wrappers with one helper that accepts the
constants.FeatureFlagwhile preserving the current frontmatter-only boolean check. - If we skip it: The validator keeps duplicate policy plumbing that must be maintained twice.
Verdict: fix 1 first.
Lean: -8 lines possible.
Generated by ✂️ Ponytail Reviewer for #74884 · codex · routed: gpt56 max · ~3 AIC · ⌖ ~1 AIC · ⊞ 118
Comment /ponytail to run again
| return found && isBoolean && enabled | ||
| } | ||
|
|
||
| func dangerouslyAllowsPullRequestTargetForksAll(workflowData *WorkflowData) bool { |
There was a problem hiding this comment.
Should fix: Duplicate dangerous-feature lookup. What this is: dangerouslyAllowsPullRequestTargetForksAll repeats the case-insensitive boolean-frontmatter lookup already implemented by dangerouslyAllowsRolesReadAndPullRequestTarget immediately above. Problem: Every new dangerous opt-in now needs another copy, so the shared lookup rules can drift. Fix: Replace both wrappers with one helper that accepts the constants.FeatureFlag while preserving the current frontmatter-only boolean check. If we skip it: The validator keeps duplicate policy plumbing that must be maintained twice.
There was a problem hiding this comment.
Consolidated the two checks into dangerouslyAllowsFeatureFlag, which accepts a constants.FeatureFlag and preserves case-insensitive boolean lookup. Commit ac6cd59b.
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /tdd, /codebase-design, and /diagnosing-bugs. Requesting changes: one test regression from this PR, plus a possible opt-in bypass through imports.
📋 Key Themes & Highlights
Blocking
- Test regression (
/tdd):TestTriggerForkFilterCompilationnow fails. Thepull_request_target/wildcardandpull_request_target/wildcard_stringsubtests inpkg/workflow/filters_forks_test.go(L24-25) expectforks: "*"to compile in strict mode. This PR rejects that, so the test needs the opt-in flag or an updated expected error. I reproduced both failures locally. This file is outside the diff, so I could not attach an inline comment.
Should address
- Import-path opt-in (
/diagnosing-bugs): see the inline comment onpull_request_target_validation.goL152. - Stale docs:
.github/aw/triggers.mdL155 still says strict mode only warns on"*". It should say strict mode rejects it unless the opt-in is set.docs/src/content/docs/reference/frontmatter-full.md(~L800) has the same stale text. The generator also produces unrelated drift on base, so hand-edit the fork paragraph.
Environmental (not attributed to this PR)
TestVerifyGitCredentialsand related tests fail onmktemppermission under/home/runner/work/_temp. I did not verify them against base.
Positive highlights
- ✅ Strict-mode check uses a small helper, following the same feature-flag pattern as the roles flag.
- ✅
TestPullRequestTargetWildcardStrictModeRequiresFeatureOptIncovers both flag values. - ✅ ADR, changeset, schema, and feature-flag docs are updated together.
@copilot please address the blocking test regression and the import-path question before re-requesting review.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~7 AIC · ⌖ ~1 AIC · ⊞ 5.4K
Comment /matt to run again
|
|
||
| if effectiveStrictMode && unrestrictedForks { | ||
| allowUnrestrictedForks := dangerouslyAllowsPullRequestTargetForksAll(workflowData) | ||
| if effectiveStrictMode && unrestrictedForks && !allowUnrestrictedForks { |
There was a problem hiding this comment.
[/codebase-design] This opt-in is read from workflowData.Features, and per the merge order in compiler_orchestrator_workflow.go (mergeImportedWorkflowConfiguration runs before validation), that map already includes features imported from other files. So an imported file may be able to set dangerously-allow-pull-request-target-forks-all and pass this strict-mode guard without the top-level workflow opting in. Consider reading this flag only from top-level frontmatter, or document the import behavior as intentional.
💡 Suggested test
Add a case where the flag comes only from an imported file, and assert that strict compilation still rejects a wildcard fork entry.
@copilot please address this.
There was a problem hiding this comment.
The strict-mode bypass now reads only the main workflow's top-level flag; imported feature maps cannot enable it. Added regression coverage for an import-only flag. Commit ac6cd59b.
| } | ||
| } | ||
|
|
||
| func TestPullRequestTargetWildcardStrictModeRequiresFeatureOptIn(t *testing.T) { |
There was a problem hiding this comment.
[/tdd] This test covers only the top-level flag path. Add the import-path boundary the guard depends on: put the flag in an imported workflow rather than the top-level frontmatter, and assert that strict compilation still rejects a wildcard fork entry. Name it as a spec, for example ImportedOptInDoesNotBypassStrictForkGuard.
@copilot please address this.
There was a problem hiding this comment.
Added TestImportedOptInDoesNotBypassStrictForkGuard, which puts the flag only in an imported workflow and asserts strict compilation rejects forks: ["*"]. Commit ac6cd59b.
|
@copilot run pr-finisher skill |
There was a problem hiding this comment.
🟡 Changes recommended
Existing wildcard compilation fixtures lack the required feature-flag opt-in, so strict mode now rejects them before their generated-condition assertions can run.
2 open issues
What changed in this PR
Tightens gh-aw’s compiler policy for unrestricted pull_request_target fork admission, requiring an explicit dangerous opt-in in strict mode.
Changes:
- Rejects wildcard fork admission by default in strict mode and warns whenever it is allowed.
- Adds the Boolean feature flag and regression coverage while preserving actor authorization and checkout safeguards.
- Updates reference documentation, the decision record, and migration guidance.
| File | Description |
|---|---|
pkg/workflow/pull_request_target_validation.go |
Enforces the opt-in and retains wildcard warnings. |
pkg/workflow/pull_request_target_forks_test.go |
Updates wildcard expectations and tests explicit opt-in. |
pkg/parser/schemas/main_workflow_schema.json |
Defines the feature flag and updated admission policy. |
pkg/constants/spec_test.go |
Checks the flag’s public string value. |
pkg/constants/README.md |
Documents the new flag constant. |
pkg/constants/feature_constants.go |
Adds the dangerous opt-in constant. |
pkg/constants/constants_test.go |
Adds coverage for the flag identifier. |
docs/src/content/docs/reference/triggers.md |
Explains strict-mode rejection and the opt-in. |
docs/src/content/docs/reference/feature-flags.md |
Documents unrestricted admission and persistent warnings. |
docs/adr/72579-apply-fork-filters-to-pull-request-target.md |
Records the stricter policy and compatibility tradeoff. |
.changeset/strict-pull-request-target-bounded-forks.md |
Updates breaking-change and migration guidance. |
Review effort: Max (auto)
|
|
||
| if effectiveStrictMode && unrestrictedForks { | ||
| allowUnrestrictedForks := dangerouslyAllowsPullRequestTargetForksAll(workflowData) | ||
| if effectiveStrictMode && unrestrictedForks && !allowUnrestrictedForks { |
There was a problem hiding this comment.
Updated the pull_request_target wildcard compilation fixtures to explicitly set the strict-mode opt-in, preserving their generated-condition assertions. Commit ac6cd59b.
| } | ||
| ], | ||
| "description": "Filter fork pull requests by repository pattern (string or list). Omission and an empty list both allow only same-repository PRs. Exact owner/repo entries or trusted owner/* patterns admit matching forks; '*' allows all forks. Strict mode warns on any '*' entry and recommends narrower admission, but compilation continues. Strict mode rejects expressions and unsupported pattern forms. Same-repository PRs remain allowed. Actor authorization and checkout restrictions remain mandatory in strict mode; acknowledge-risk neither bypasses them nor suppresses the fork warning. This does not change GitHub's base-repository permissions or secret availability for pull_request_target." | ||
| "description": "Filter fork pull requests by repository pattern (string or list). Omission and an empty list both allow only same-repository PRs. Exact owner/repo entries or trusted owner/* patterns admit matching forks; '*' allows all forks. Strict mode rejects any '*' entry unless features.dangerously-allow-pull-request-target-forks-all is true; non-strict mode warns. The warning remains when the flag is enabled. Strict mode rejects expressions and unsupported pattern forms. Same-repository PRs remain allowed. Actor authorization and checkout restrictions remain mandatory; acknowledge-risk neither bypasses them nor suppresses the fork warning. This does not change GitHub's base-repository permissions or secret availability for pull_request_target." |
There was a problem hiding this comment.
Updated the schema-backed frontmatter reference and feature list, trigger guide, feature-flag docs, and changelog to explain strict rejection, the top-level opt-in, and persistent warnings. Commit ac6cd59b.
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Completed the finisher pass and pushed commit |
|
🎉 This pull request is included in a new release. Release: |
…forks flag Document safe-output output_id/depends-on dependency gating (#74376), the managed source-sha frontmatter field (#74948), the dangerously-allow-pull-request-target-forks-all feature flag (#74884), and detection report-as-issue permission requirements (#74949). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>


Unrestricted fork admission can expose privileged
pull_request_targetworkflows to attacker-controlled PR content, even when the triggering actor is trusted or checkout is disabled. Strict mode now rejectsforks: ["*"]by default; non-strict mode warns.features.dangerously-allow-pull-request-target-forks-all: trueto permit*in strict mode. The warning remains, and actor authorization and checkout restrictions are unchanged.