Why do fork PRs get no secrets, and what is `pull_request_target`?
AdvancedConceptGitHub features, history rewriting and scale
Answer
For pull_request events from forks, secrets are withheld and the token is read-only, so untrusted code cannot steal them. pull_request_target runs in the base repo context with secrets, so checking out and running fork code in it is a well-known remote-code-execution risk. Never execute untrusted PR code in that trigger.
More on GitHub features, history rewriting and scale
What does a GitHub Actions workflow look like at a basic level?BeginnerWhat are GitHub environments and what protection do they offer?IntermediateWhat is a GitHub Release and how does it relate to a Git tag?BeginnerWhat are the permissions of `GITHUB_TOKEN` and how do you restrict them?IntermediateWhat is the difference between a GitHub fork and a clone?BeginnerWhat is a branch protection rule versus a ruleset?Intermediate