Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

A secure CI/CD pipeline does not treat every pull request, workflow, runner, and credential as equally trustworthy. The key is to put a clear boundary between untrusted contribution code and the authority to change repositories, access secrets, or deploy software. For GitHub Actions, that means testing fork pull requests with the restricted pull_request event, keeping permissions minimal, and granting deployment access only in a separate trusted context.

What a CI/CD trust boundary protects

A pull request can contain more than application changes. Its source code, workflow edits, dependencies, and even text consumed by automation may be controlled by someone outside the repository’s trusted team. Meanwhile, a pipeline may hold tokens, secrets, access to persistent runners, or permission to deploy. If untrusted input can execute while those authorities are available, the pipeline connects attacker-controlled code to sensitive capabilities.

A trust boundary is the control point that limits that connection. It is not one setting: it is the combined decision about which event runs, which workflow definition is used, what code can execute, what credentials are exposed, what the token can do, and what runner environment the job can reach.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the event according to the trust level

Event Trust context and access Appropriate use
pull_request For fork contributions, GitHub runs the pull-request workflow with a read-only GITHUB_TOKEN and withholds other secrets by default. Run tests and checks that do not require secrets or write authority.
pull_request_target Runs the base repository’s workflow in the base repository’s trust context, with access to repository and organization secrets and a privileged token. Use only for tasks that need that context and do not execute untrusted pull-request code.

The hazardous combination is not simply a particular event name; it is privileged authority combined with untrusted execution. GitHub warns: “Workflows triggered by this event should not check out, build, or run code from an untrusted pull request with access to repository secrets or a privileged GITHUB_TOKEN.” See GitHub’s guidance on securely using pull_request_target.

#1 Best Overall

Do not use a privileged workflow to check out a fork’s branch and then build, test, or run it. A workflow can be triggered by a contribution yet still have powerful access; the safe question is whether the job executes code controlled by that contributor while holding that access.

Separate testing authority from deployment authority

Keep untrusted pull-request jobs low privilege

Use the ordinary pull_request event for fork checks that need no secrets. Give each job only the token permissions it requires; tests generally should not need repository write access. Do not add secrets or write permissions to an untrusted job just to make a check pass. GitHub’s secure use reference and the OWASP CI/CD Pipeline Security guideline both emphasize least privilege and protecting secrets from untrusted pull requests.

Give deployment credentials only to the trusted deployment context

Keep deployment credentials out of jobs that execute contribution code. A deployment job should run only after the repository’s required review and merge controls have established that its code and workflow are trusted. Its permissions and credentials should be limited to the deployment it performs; a test job should not inherit them merely because both jobs are in one workflow.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Before granting a job authority, establish what it can execute and who controls that input. A workflow change can itself alter the pipeline’s behavior, so workflow definitions deserve code review and appropriate repository protections alongside application source.

Protect the runner and the pipeline’s dependencies

Treat runners as part of the security boundary

Untrusted code can affect more than the current test result if the environment retains state. GitHub warns that self-hosted runners do not have guaranteed clean, ephemeral virtual machines and can be persistently compromised by untrusted workflow code. Do not send fork pull-request jobs to a self-hosted runner that has sensitive files, credentials, network access, or state reused by trusted jobs. Runner isolation and cleanup are security controls, not just operational details. See the GitHub secure use reference.

Review workflow code and constrain actions

Workflow files and third-party actions are executable parts of the build. An action can receive inputs and tokens available to its step or job, so use only actions you trust, review changes to workflow definitions, and grant narrow permissions. Where appropriate, pin action references to full commit SHAs rather than mutable tags. A full SHA makes the referenced revision explicit; it does not replace reviewing that code or updating the pin when a safe update is needed. GitHub covers third-party action risks and pinning in its secure use reference.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use OIDC instead of stored cloud credentials where supported

For supported cloud providers and identity systems, OpenID Connect (OIDC) can let a workflow obtain short-lived credentials through federation rather than storing a long-lived cloud credential as a repository secret. GitHub recommends OIDC for supported cloud resources. The workflow still needs narrowly scoped identity permissions: federation removes the need to store a persistent credential in the repository, but it does not make an over-permissioned deployment identity safe. HashiCorp documents an example of GitHub Actions authenticating to Vault with a GitHub-issued OIDC token in its GitHub Actions and Vault guidance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quick Recap

Bestseller No. 1
SaleBestseller No. 3
SaleBestseller No. 4

Review the boundary before enabling a workflow

  • Input: Which source, workflow changes, dependencies, or pull-request content can this job execute or consume?
  • Event: Does the trigger provide the base repository’s trust context, or the restricted context intended for fork checks?
  • Token: What exact permissions does the job need, and can any write permission be removed?
  • Secrets: Which secrets are visible to the job, and does any untrusted code run while they are available?
  • Runner: Is the environment isolated and clean, or can untrusted code leave state that a trusted job later encounters?
  • Dependencies: Which actions can run, who controls them, and are their references pinned and reviewed?
  • Deployment: Does deployment authority exist only in a trusted job, with the minimum required scope?

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.