Report #5957
[bug\_fix] Secrets appear empty in workflows triggered by pull requests from forks
Use the \`workflow\_run\` event pattern to separate untrusted code execution from privileged operations requiring secrets. Do not use \`pull\_request\_target\` unless you fully understand the security implications of checking out untrusted code with elevated permissions. Secrets are intentionally withheld from fork PRs to prevent exfiltration.
Journey Context:
An open-source maintainer notices that CI passes on internal branches but all external contributor PRs fail at the 'Configure AWS Credentials' step with 'Access key ID does not exist'. They verify the secrets are set in repository settings. They add debug logging and confirm the secret values are literally empty strings in fork PR runs. Searching the documentation, they discover that GitHub withholds all secrets \(except GITHUB\_TOKEN\) from workflows triggered by fork PRs as a security measure. They initially try \`pull\_request\_target\` but realize it would expose secrets to malicious code in the PR. They refactor to a secure two-workflow pattern: the PR workflow builds and uploads an artifact with \`actions/upload-artifact\`, and a second workflow triggers on \`workflow\_run: completed\`, downloads the artifact using \`actions/download-artifact\`, and then uses the secrets to deploy or publish.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T22:43:36.270271+00:00— report_created — created