Skip to content

Require explicit opt-in for unrestricted pull_request_target forks - #74884

Merged
pelikhan merged 4 commits into
mainfrom
copilot/investigate-security-implications
Nov 4, 2026
Merged

pelikhan merged 4 commits into
mainfrom
copilot/investigate-security-implications

Conversation

Copilot AI commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Unrestricted fork admission can expose privileged pull_request_target workflows to attacker-controlled PR content, even when the triggering actor is trusted or checkout is disabled. Strict mode now rejects forks: ["*"] by default; non-strict mode warns.

  • Policy: Strict mode requires bounded fork patterns unless the dangerous opt-in is enabled. Non-strict mode continues to allow unrestricted admission with a warning.
  • Opt-in and safeguards: Set features.dangerously-allow-pull-request-target-forks-all: true to permit * in strict mode. The warning remains, and actor authorization and checkout restrictions are unchanged.
  • Docs and coverage: Updated the feature schema, reference docs, decision record, changeset, and regression tests.
on:
  pull_request_target:
    forks: ["*"]
features:
  dangerously-allow-pull-request-target-forks-all: true

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate security implications of unrestricted fork admission Require explicit opt-in for unrestricted pull_request_target forks Nov 4, 2026
Copilot AI requested a review from pelikhan November 4, 2026 16:15
@pelikhan
pelikhan marked this pull request as ready for review November 4, 2026 16:44
Copilot AI dynamic review requested due to automatic review settings November 4, 2026 16:44
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

✅ 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: reported_no_action

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.

Generated from Design Decision Gate 🏗️ · routed: opus55 medium · ~11 AIC · ⌖ ~2 AIC · ⊞ 7.7K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

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.

Generated from Test Quality Sentinel · routed: gpt56 max · ~1 AIC · ⌖ ~1 AIC · ⊞ 6.3K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Generated by Ponytail Reviewer for #74884

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-04T16:48:38Z
review_event: COMMENT
top_themes: imported dangerous feature opt-in can silently broaden fork admission
files_reviewed: pkg/workflow/pull_request_target_validation.go, pkg/workflow/pull_request_target_forks_test.go, pkg/workflow/imports.go, pkg/workflow/compiler_orchestrator_workflow.go
comment_count: 1

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~4 AIC · ⌖ ~1 AIC · ⊞ 1.6K · ◷
Comment /review to run again

@github-actions github-actions Bot 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.

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)

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.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@github-actions github-actions Bot 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.

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:

  1. 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.FeatureFlag while 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 {

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.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Consolidated the two checks into dangerouslyAllowsFeatureFlag, which accepts a constants.FeatureFlag and preserves case-insensitive boolean lookup. Commit ac6cd59b.

@github-actions github-actions Bot 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.

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): TestTriggerForkFilterCompilation now fails. The pull_request_target/wildcard and pull_request_target/wildcard_string subtests in pkg/workflow/filters_forks_test.go (L24-25) expect forks: "*" 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 on pull_request_target_validation.go L152.
  • Stale docs: .github/aw/triggers.md L155 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)

  • TestVerifyGitCredentials and related tests fail on mktemp permission 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.
  • ✅ TestPullRequestTargetWildcardStrictModeRequiresFeatureOptIn covers 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 {

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.

[/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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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) {

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.

[/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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added TestImportedOptInDoesNotBypassStrictForkGuard, which puts the flag only in an imported workflow and asserts strict compilation rejects forks: ["*"]. Commit ac6cd59b.

@pelikhan

pelikhan commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

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.

🟡 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 {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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>

Copilot AI commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

@copilot run pr-finisher skill

Completed the finisher pass and pushed commit ac6cd59b with the review fixes. Local validation passed. CI is now stale and needs a maintainer re-trigger; the review comments have replies, but I cannot resolve threads with the available tooling.

@pelikhan
pelikhan merged commit a7b4146 into main Nov 4, 2026
92 checks passed
@pelikhan
pelikhan deleted the copilot/investigate-security-implications branch November 4, 2026 18:03
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.0

github-actions Bot added a commit that referenced this pull request Nov 5, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate security implications of pull_request_target with unrestricted fork admission

3 participants