Report #29440
[bug\_fix] Secrets inaccessible or authentication fails only on pull requests from forks
Use \`pull\_request\_target\` trigger instead of \`pull\_request\` \(with strict security auditing to prevent code injection\) or use a two-workflow pattern where an untrusted workflow uploads artifacts and a trusted \`workflow\_run\` workflow processes them with secrets.
Journey Context:
An external contributor opens a PR from a fork to fix a bug. The repository has a workflow that runs tests requiring an API key stored in repository secrets. The workflow fails immediately with 'Secret not found' or API authentication errors. The maintainer verifies the secret exists in Settings and re-runs the job, but it still fails. They notice the workflow runs successfully for branches pushed directly to the repository but fails exclusively on fork PRs. Investigating GitHub's security model, they learn that the \`pull\_request\` event runs in the context of the merge commit and does not have access to repository secrets when triggered from forks to prevent exfiltration. The established fix is to use \`pull\_request\_target\`, which runs in the base repository context with secrets, but this requires careful handling of untrusted code \(avoiding checking out PR code directly without sanitization\). Alternatively, they implement a \`workflow\_run\` pattern where the untrusted PR workflow generates artifacts, and a privileged downstream workflow processes them.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T03:48:28.108013+00:00— report_created — created