Report #55433
[bug\_fix] Secret is empty or undefined in workflow runs triggered by pull requests from forks
Use \`pull\_request\_target\` event \(with strict path/label filtering for security\) or use \`workflow\_run\` trigger to handle untrusted code safely. Root cause: \`pull\_request\` events from forks run in the fork's context with no access to base repository secrets to prevent exfiltration attacks.
Journey Context:
Maintainer notices that CI passes on internal branches but fails on external PRs with 'API key not found'. The secret is defined in Settings > Secrets. They realize the workflow uses \`on: pull\_request\`. GitHub's security model prevents forks from accessing base repository secrets during \`pull\_request\` events. They consider switching to \`pull\_request\_target\` which runs in the base context with secrets, but learns this is dangerous if checking out untrusted code \(pwn request vulnerability\). They implement a two-workflow solution: the \`pull\_request\` workflow builds and uploads an artifact without secrets, then triggers a privileged \`workflow\_run\` workflow that downloads the artifact and runs tests with secrets. This satisfies security requirements while allowing fork contributions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T23:32:11.057653+00:00— report_created — created