Skip to main content
Next Defence - Next-Gen AI Cyber Security Firm
Australia & New Zealand[email protected](02) 9064 2614
INSIGHT

Protecting CI Runners From Untrusted Pull Requests

Continuous integration can turn an untrusted pull request into useful feedback in minutes. That convenience becomes dangerous when the same runner also holds deployment secrets, signing keys or access to.

Continuous integration can turn an untrusted pull request into useful feedback in minutes. That convenience becomes dangerous when the same runner also holds deployment secrets, signing keys or access to other projects’ build files. An outside contributor may not need to compromise the code host if their proposed change causes privileged automation to execute instructions from a lower-trust context. CI security requires a deliberate separation between testing unreviewed code and producing trusted releases. This article uses fictional repositories and harmless test markers; it does not describe an intrusion into a specific development team.

Treat a pull request as data from a lower-trust party

A pull request can include scripts, package manifests, test configuration and dependencies that will execute during a build. A reviewer may examine the application code while overlooking a changed workflow file or build hook. Decide which events may trigger CI for an external fork and which privileges are available in that context. The correct default is to assume unreviewed code can behave adversarially, even when it originates from a contributor with a credible public profile.

Keep the first-stage checks limited to tasks such as formatting, static analysis and isolated unit tests. They should not need production credentials or write permission to protected repository branches. If a test genuinely requires privileged infrastructure, split it into a separately authorised stage that uses reviewed input and a stronger trust boundary.

Avoid passing deployment secrets to untrusted jobs

Inspect how the CI platform injects environment variables, tokens and cloud credentials. A token may be available through the runtime environment, a mounted file, a metadata service or a reusable action. Disabling one obvious variable is not enough if the runner has broad ambient cloud permissions. Review effective scopes and make credentials short-lived and task-specific where supported.

Test with dummy secret values inside a disposable repository. Attempt to reference the markers from the fork’s test script and verify that they are unavailable. Do not use real production secrets in a demonstration or print sensitive material into diagnostic logs to prove access. A reliable control prevents disclosure before the test starts, rather than relying on later masking of console output.

Keep runners ephemeral and workspaces isolated

A persistent runner can carry files and state between jobs. An untrusted build might change a local tool, write to a shared cache or leave an artefact that a later privileged job consumes. Prefer clean, disposable execution environments for external contributions where practical. If a persistent runner is unavoidable, review its cleanup, filesystem permissions, network reach and ability to accept jobs from differing trust levels.

Caches deserve separate scrutiny. A dependency cache can accelerate work but may also become a path for code substitution if a lower-trust job can write data later read by a trusted release. Review cache key scopes and permissions, and consider separate cache namespaces or immutable artefact promotion. A build being fast is not evidence that its inputs are trustworthy.

Define the trusted release boundary

A reviewed merge to a protected branch should be the entry point for release packaging, signing and deployment. Record the commit, build environment, approved dependencies and resulting artefact digest. Restrict who can change the workflow that performs this promotion. A successful unit-test run on an untrusted pull request should not itself be capable of publishing an official package or modifying production infrastructure.

Review reusable workflows and third-party actions as part of the supply chain. If external code is loaded at build time, use controlled versions and appropriate integrity assurances. The release process should be able to show that the deployed artefact came from reviewed source under approved automation, rather than an arbitrary file supplied by an earlier job.

Test a harmless fork-to-release attack path

Create a disposable repository with a synthetic deployment token that has no real authority. Submit a pull request containing a script that attempts to read a dummy secret and write a recognisable marker to a cache or shared workspace. Observe whether the untrusted job can access those resources and whether any marker is visible in a subsequent trusted-stage test. The aim is to prove separation without abusing a live workflow.

Capture job event type, token permissions, runner identity, cache policy and resulting audit events. A failed malicious command because a particular tool is absent is a weaker result than a known permission denial. Investigate both the platform configuration and the runner’s effective environment before approving the boundary.

Examine workflow trigger and approval rules

Different CI events can carry different privilege assumptions. Review how the platform treats forked pull requests, repository-internal branches, tags and manually dispatched jobs. A configuration intended for trusted maintainers may accidentally execute with privileged context when it processes an external pull request. Document which events are allowed to use secrets and which require an explicit reviewer or protected environment.

Approval controls should identify changes to the automation itself. A contributor who alters a build script may achieve the same effect as editing the CI workflow file. Treat scripts called by privileged steps as part of the release trust boundary, and inspect changes to their behaviour before promotion.

Detect misuse without exposing more secrets

CI audit logs should show who triggered a job, which repository revision ran, what permissions were granted and which protected environment was used. Alert on unexpected workflow changes, unusual secret-access attempts and deployments outside approved branches. Preserve enough context to investigate a suspect build but avoid placing full tokens or confidential source material into widely accessible console logs.

If a privileged runner is suspected of misuse, the response may include stopping affected jobs, rotating relevant credentials, preserving runner images and verifying released artefacts. The incident owner should assess scope from evidence, not assume that every package built on the platform was malicious. Rebuild affected releases from a trusted baseline where the investigation supports that decision.

Make developers’ safe path convenient

A secure process that makes every outside contribution unbearably slow may drive teams toward unsafe workarounds. Provide a quick untrusted test stage with useful feedback, followed by an efficient reviewed route into privileged integration and deployment. Make the escalation process clear for urgent fixes. A time-sensitive security patch does not justify letting a fork run with full production authority.

Retest the controls when adding reusable actions, new cloud identities, runner pools or dependency caches. The acceptance outcome is straightforward: external contributions can be tested without secrets or persistent privileged state, while only approved source and automation can create official release artefacts. That distinction protects both developers’ workflow and the customers who rely on what the team ships.

Verify that logs do not become the exfiltration route

Some CI tools mask known credential values in console output, but that feature cannot be relied upon to protect every transformation or encoding of a secret. The safer control is denying access to privileged material from untrusted jobs. In a sandbox, attempt only harmless dummy-marker reads and inspect whether logs reveal the marker through normal output, test reports or uploaded artefacts. This helps the team understand leakage paths without putting genuine cloud keys at risk.

Configure permissions for test-result uploads separately from release publishing. An external contribution should be able to return useful test diagnostics while being unable to overwrite a trusted build artefact or silently change a deployment approval record.

Operational decision and evidence card

Use this evidence card at sign-off to distinguish a control that is present from a control that has been witnessed. Its business purpose follows external pull request to isolated tests to reviewed merge to trusted build to signed release deployment. If the system cannot show the requested evidence, mark the control unverified rather than treating silence in a dashboard as a successful denial.

Review element Required observation
Operational workflow external pull request to isolated tests to reviewed merge to trusted build to signed release deployment
Authorised result a fork contribution receives lint and unit-test feedback without obtaining any cloud or release credentials
Prohibited result a pull-request script cannot read long-lived secrets, write a shared cache or produce an unreviewed production artefact
Safe exercise run a harmless synthetic fork with attempts to read dummy secrets and cross-run cache markers in disposable runners
Evidence sources workflow trigger policy, token scopes, runner lifecycle, cache permissions, build attestations and audit events
Exceptional circumstance a team asks to use a privileged runner to speed integration tests on a time-sensitive security fix
Governed response split the untrusted test stage from a separately approved trusted deployment context rather than grant the fork privileges
Acceptable outcome fork tests cannot cross the trust boundary and only reviewed commits on protected branches can create release artifacts
Important limit test only owned repositories and approved lab secrets; never publish real tokens in diagnostic logs

Sources and further reading

How Next Defence can help

Build an approved acceptance exercise around preventing an untrusted pull request from reading CI runner secrets or publishing a release. Keep ephemeral runner identity, blocked secret access and verified build provenance with the acceptance record. Application Security & DevSecOps can help scope the tests and clarify who must authorise any live-system change.

LET'S TALK

Let’s talk about your security.

Tell us what you are protecting, where you need greater visibility or what you want to achieve. We will help identify the right next step.

Talk to a Security Specialist

Describe your security requirements. Please do not submit passwords, credentials or confidential incident evidence. This form is not an emergency incident-response channel.

Form powered by HubSpot. Review our Privacy Policy. If the form doesn’t load, email [email protected].