pull_request_target is a GitHub Actions trigger that runs in the context of the target repository rather than the incoming pull request repository. That means it can access target-repository secrets and write permissions. It is useful for some review workflows, but it becomes dangerous if the workflow checks out and executes untrusted incoming code.
What pull_request_target changes
pull_request_target is powerful because it evaluates a pull request against the target repository’s permissions, secrets, and workflow context. That makes it suitable for review automation, labeling, and other trusted maintenance tasks, but it also means the workflow must be written as if the incoming branch is hostile until proven otherwise.
Its core security implication is trust boundary placement: the event gives the workflow more authority than the contributor’s fork. If maintainers treat it like an ordinary pull request trigger, a malicious change can turn a review workflow into a secret-exfiltration or write-access path.
Why pull_request_target is dangerous
The danger comes from confusion between who submitted the code and whose context the workflow runs in. If the job checks out untrusted code and then executes it, an attacker can use that privileged context to read repository secrets, tamper with releases, or abuse write permissions that were never meant to be exposed to forked content. NHIMG’s OWASP CI/CD Top 10 CICD-SEC-4 Poisoned Pipeline Execution Guide explains the broader poisoned-pipeline pattern this trigger can enable.
The practical failure mode is usually not the trigger itself, but the combination of privileged execution plus untrusted input. That is why review comments, metadata handling, and path-based automation can be safe while checkout-and-run patterns are not.
Common exploitation pattern
Attackers look for workflows that use pull_request_target, then sneak in a payload through the pull request contents, scripts, generated files, or downstream tooling. Once the workflow runs in the target repository context, the attacker may be able to trigger secret reads, token use, or privileged writes without ever compromising the main branch directly.
This is especially attractive in open source and dependency projects because maintainers often want automation on external contributions. NHIMG’s Supply chain NHI breaches and Top 10 CI/CD Security Risks show how a single workflow mistake can cascade into token theft, release poisoning, and wider supply-chain compromise.
Safer use cases and boundary conditions
pull_request_target is not inherently wrong. It is useful when the workflow only needs repository metadata, labels, comments, or other operations that do not require executing attacker-controlled code. The safe pattern is to keep privileged actions narrowly scoped and to treat any content from the incoming pull request as untrusted data, not executable logic.
When a workflow truly needs to inspect code from an external contribution, the safer design is to separate trust levels, restrict permissions, and avoid giving the untrusted portion access to the target repository’s secrets or write-capable tokens. NHIMG’s GitHub and GitHub Actions Security Guide and OWASP CI/CD Top 10 CICD-SEC-4 Poisoned Pipeline Execution Guide both emphasise this separation of trust and execution.
What to review after adoption
Any repository using pull_request_target should be reviewed for secret exposure, token scope, checkout behaviour, and whether the workflow can be reached from forked contributions. A good rule is that the more privileges a workflow has, the less it should do with untrusted pull request content.
Detection and auditability matter after the fact as well. If a privileged workflow is abused, maintainers should be able to trace what ran, what it accessed, and whether credentials or release artefacts need rotation or replacement. NHIMG’s Detection Engineering Guide is a useful companion for building that visibility into pipeline activity.
Risk and Threat Considerations
pull_request_target creates a high-value attack surface because it deliberately runs with the target repository’s trust, not the contributor’s. That makes it attractive for secret theft, poisoned pipeline execution, and unauthorized writes whenever untrusted code or generated content is allowed anywhere near the privileged job.
Failure mechanism: The workflow combines elevated repository context with attacker-influenced inputs, then executes or processes those inputs in a way that exposes secrets, tokens, or write permissions.
Impact: A successful abuse can leak credentials, alter releases, plant malicious workflow logic, or let an attacker pivot from a single pull request into broader repository or supply-chain compromise.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP API Security Top 10 and MITRE ATT&CK address the attack and risk surface, while CIS Controls v8 and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP API Security Top 10 | API8 — Security Misconfiguration | Privileged workflow exposure often stems from unsafe GitHub Actions configuration. |
| Recommendation — Harden workflow permissions and execution paths to remove unsafe privileged access. | ||
| CIS Controls v8 | CIS-16 — Application Software Security | CI/CD workflows are software delivery assets that need secure configuration and review. |
| Recommendation — Review workflow logic and trust boundaries before granting repository-level privilege. | ||
| NIST SP 800-53 Rev 5 | AC-6 — Least Privilege | This trigger becomes risky when workflows receive more access than the task needs. |
| IA-5 — Authenticator Management | Secrets and tokens used by privileged workflows must be managed carefully when exposed to forked input. | |
| Recommendation — Limit workflow permissions to the minimum required for each job. Rotate and protect credentials that privileged workflows can reach. | ||
| MITRE ATT&CK | T1190 — Exploit Public-Facing Application | Abuse of privileged workflow entry points can be part of initial access and execution paths. |
| Recommendation — Monitor exposed workflow endpoints and investigate abuse of privileged automation. | ||
Practitioner Guidance
Why practitioners should care: This trigger is one of the few GitHub Actions events that can turn a harmless-looking review workflow into a privileged control plane for the repository. That is why it demands explicit ownership and review, not just normal CI hygiene.
Common misunderstanding: Many teams assume that “pull request” automatically means “safe to run code from the PR.” With pull_request_target, the opposite assumption is safer: the workflow is trusted unless you deliberately constrain it.
Practitioner takeaway: Use pull_request_target only for narrowly bounded maintenance actions, and design every privileged step so it remains safe even if the incoming pull request is malicious.
Related resources from NHI Mgmt Group
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on October 31, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org