A Pull Request is a proposal to merge code changes from one branch or fork into another, opened for review and automated checks before merging. It is a control point: branch protection and required reviews keep unreviewed code off protected branches. Attackers submit malicious changes or trigger CI workflows that expose secrets, so withhold secrets from untrusted pull requests.
What a pull request actually controls
A pull request is more than a merge request. It is the review gate where change intent, diff quality, automated checks, and policy enforcement meet before code enters a protected branch. That makes it a governance checkpoint as much as a collaboration feature, because the decision to merge determines what is trusted, shipped, and later inherited by downstream builds and deployments.
The practical security value of the control is that it slows the path from “someone changed code” to “the organisation now relies on that code.” Review requirements, status checks, and branch rules are meant to catch malicious edits, accidental breakage, and policy bypass before the change becomes part of the durable codebase.
How pull requests reduce change risk
Pull requests reduce risk by separating proposal from acceptance. Instead of allowing direct pushes into a main branch, teams can require code review, test results, and approval from the right owners. This matters because the diff is where most malicious or unsafe change is visible, and because reviewers can spot suspicious logic, hidden dependency changes, and workflow edits that would be easy to miss in a fast merge.
In practice, the control is strongest when the repository enforces it consistently. If protected branches can still be updated through exceptions, bypass rules, or overly broad permissions, the pull request becomes a suggestion rather than a gate.
Where pull requests become an attack surface
Pull requests are attractive to attackers because they create a trusted review path into software delivery. A malicious contributor can try to hide backdoored code inside a plausible change, while a weaker but more common failure mode is workflow abuse, where a PR causes CI to execute code in a context that can read credentials or influence privileged automation. The danger is often not the merge itself, but what the CI system is allowed to do while validating the change.
Untrusted forks and PR-triggered workflows are especially sensitive because they can expose secrets, tokens, or write-capable automation if the pipeline is configured too broadly. The safest assumption is that PR content is untrusted until review and policy checks have completed.
What good pull request hygiene looks like
Strong pull request hygiene combines branch protection, required review, least-privilege CI permissions, and careful handling of secrets in review builds. Reviewers should understand which changes affect application logic, which alter pipeline behaviour, and which touch deployment or credential-handling code. SAST, SCA and code scanning tool rollout playbook is useful here because it shows how pull request gates, code owner routing, and scanner baselines work together in a real rollout.
When PRs are used to gate security-relevant code, teams also need clear rules for secrets and workflow permissions. How to Restrict GITHUB_TOKEN Permissions in Workflows is a useful companion for tightening the automation side, while Secure Code Review Checklist helps reviewers look past style and focus on the security properties of the change.
Risk and Threat Considerations
Pull requests are a security control point, but they also create a common abuse path for untrusted code, malicious workflow triggers, and secret exposure. The biggest risk is assuming that “review required” alone is enough, when the surrounding CI configuration may still execute attacker-influenced code or pass sensitive tokens into the job context.
Failure mechanism: An attacker submits code or triggers a workflow through a PR path that was meant to be read-only, then abuses that execution context to steal secrets, alter build outputs, or smuggle malicious logic past review.
Impact: The result can be credential exposure, supply-chain compromise, merged backdoored code, or a compromised release process that looks legitimate until downstream systems are affected.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
NIST SP 800-53 Rev 5, CIS Controls v8 and OWASP ASVS set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST SP 800-53 Rev 5 | AC-3 — Access Enforcement | Pull request gates enforce who may merge protected code changes. |
| IA-5 — Authenticator Management | PR workflows must protect and rotate credentials that can be exposed during untrusted builds. | |
| CM-3 — Configuration Change Control | A pull request is the formal change-control point for code and workflow updates. | |
| Recommendation — Enforce merge permissions on protected branches and require approval before code enters production paths. Restrict workflow tokens and rotate any credentials exposed to untrusted pull request execution. Require review and approval for repository and pipeline changes before merge. | ||
| CIS Controls v8 | CIS-6 — Access Control Management | PR review and branch protection reduce unnecessary write paths into critical branches. |
| Recommendation — Limit who can merge, approve, and administer repositories and CI workflows. | ||
| OWASP ASVS | V16 — Security Logging and Error Handling | PR-driven review and CI checks depend on logging and traceability for change validation. |
| Recommendation — Log review actions and workflow outcomes so suspicious pull request activity can be investigated. | ||
Practitioner Guidance
Why practitioners should care: Treat the pull request as a policy boundary, not just a developer convenience feature. If branch rules, reviewer requirements, and workflow permissions are inconsistent, the control stops being a meaningful trust gate.
What to watch for: Pay close attention to PRs that touch workflow files, build scripts, dependency manifests, or token-handling logic. Those changes often have a larger security impact than their size suggests, and they deserve stricter review than ordinary application code.
Practitioner takeaway: A secure pull request process is only as strong as the CI permissions, secret handling, and branch protections that surround it.
Related resources from NHI Mgmt Group
- Should organisations allow pull_request_target for automated dependency workflows?
- What breaks when untrusted pull request content is executed in a workflow?
- What do security teams get wrong about pull_request_target workflows?
- Why do pull_request_target workflows create more risk than standard pull request workflows?
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 November 26, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org