Report #81866
[bug\_fix] Secrets resolve to empty string or 'Input required and not supplied' only for pull requests from forks
Use \`pull\_request\_target\` event instead of \`pull\_request\` for workflows that need secrets to comment on PRs, BUT only checkout the base repository code \(not the PR code\) or use explicit HEAD commit checking with isolation. Alternatively, use the \`workflow\_run\` pattern: an unprivileged \`pull\_request\` workflow uploads artifacts, then a privileged \`workflow\_run\` workflow \(which has secrets\) downloads them and posts comments. The root cause is that GitHub deliberately withholds secrets from \`pull\_request\` events triggered by forks to prevent secret exfiltration by malicious PRs.
Journey Context:
A developer creates a workflow that posts a comment with test coverage results using a secret API token \(or GITHUB\_TOKEN with write permissions\). It works perfectly for internal team members pushing branches, but fails for every external contributor's pull request with "Error: Input required and not supplied: token" or the secret resolves to an empty string. The developer checks the workflow and the secret is definitely configured in Settings > Secrets. They search and discover that GitHub Actions does not pass secrets to workflows triggered by \`pull\_request\` events from forks as a security measure against pwn requests. They initially try switching to \`pull\_request\_target\` which does have access to secrets, but then realize this is dangerous because \`actions/checkout\` defaults to checking out the PR code \(potentially malicious\) into a privileged context. They learn the secure patterns: either use \`pull\_request\_target\` but explicitly checkout the base ref \(not the PR ref\) for operations like labeling or commenting that don't need to execute the PR code, or use the two-workflow pattern where an unprivileged \`pull\_request\` workflow uploads artifacts, and a privileged \`workflow\_run\` workflow \(which has access to secrets and runs in the base context\) downloads those artifacts and posts the comment.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T20:00:18.912352+00:00— report_created — created