Join our Newsletter — 33% off our NHI Course
Home FAQ Cyber Security What should security teams do first when self-hosted…
Cyber Security

What should security teams do first when self-hosted CI/CD runners are used in public repositories?

← Back to all FAQ
By NHI Mgmt Group Editorial Team Updated September 9, 2026 Domain: Cyber Security

Start by treating self-hosted runners as high-risk infrastructure, not trusted build capacity. Restrict which events can trigger workflows, especially from external pull requests, and isolate runners that process untrusted code. Apply least privilege to tokens, block unnecessary network egress, and review workflow permissions so a malicious contribution cannot reach secrets, persistence, or release artifacts.

Why public-repo runners deserve immediate containment

Self-hosted CI/CD runners in a public repository change the trust model of the build pipeline. Code from outside the organisation can influence what the runner executes, which makes the runner part of the attack surface rather than a neutral utility. The first priority is to constrain exposure before optimising speed or convenience, because a single over-permissive workflow can turn ordinary contribution handling into credential theft, artifact tampering, or lateral movement. NIST’s control catalogue for system and account protections is a useful baseline here, but the operational decision starts with reducing trust in the runner itself rather than assuming the repository boundary is enough. In practice, many teams discover the weakness only after an external pull request has already exercised a workflow path they assumed was harmless.

How the first control decision changes the whole pipeline

The practical first step is to separate trusted automation from untrusted execution paths. That means identifying which workflow events can reach a self-hosted runner, then narrowing that set so unreviewed contributions do not automatically inherit the same execution environment as internal builds. Public repositories often need a split design: one lane for isolated validation of untrusted code, and another for protected release or deployment jobs that only run after stronger trust checks. If a runner must touch secrets, deployment tokens, or package publishing steps, it should not also be the default target for pull-request code from unknown authors.

A sound operating model usually includes three decisions made in order:

  • Decide which events are allowed to schedule jobs on self-hosted runners.
  • Separate runners that handle untrusted code from runners that can reach sensitive systems.
  • Limit token scope, workflow permissions, and outbound network access so job code cannot expand its own reach.

This is also where teams should review whether the runner can be reimaged or reset quickly after each job. If the environment persists between runs, a malicious workflow may leave behind tooling, modified binaries, cached secrets, or altered configuration that later jobs inherit. The guidance becomes weaker when runners are shared across trust zones, when the workflow engine allows broad event triggers, or when the build environment can reach internal services that are not required for compilation. NIST SP 800-53 Rev 5 Security and Privacy Controls is useful as a control reference, but the operational lesson is to treat runner placement and trigger design as the real security boundary.

Where the usual runner pattern breaks down

Tighter isolation often increases workflow complexity, so organisations have to balance safer execution against slower builds and more maintenance overhead. The common failure mode is assuming that a public repository only needs review controls at the pull-request layer, while leaving the runner itself broadly reachable from the internet, internal networks, or privileged service accounts. That assumption breaks down quickly when a build step can access caches, package registries, deployment endpoints, or cloud metadata that were never intended for untrusted code.

There is also a meaningful trade-off between friction and safety. The more a team wants to preserve fast feedback on public contributions, the more carefully it must separate validation from release. Some organisations use ephemeral or containerised runners for untrusted work and reserve persistent self-hosted runners for trusted branches only; others decide the operational burden is too high and move untrusted public-repo jobs off self-hosted infrastructure entirely. The right answer depends on whether the runner is merely a convenience layer or a system that can affect production trust.

One edge case is that not every self-hosted runner is equally dangerous. A locked-down runner with no secrets, no outbound reach, and no persistence presents a much smaller exposure than a general-purpose build host. The guidance weakens when the runner is already segmented, disposable, and incapable of reaching anything valuable. Even then, teams should still verify that job permissions, artifact publishing paths, and branch protections match the actual trust level of the code being executed.

Risk and Threat Considerations

Self-hosted runners in public repositories create a direct exposure path from untrusted code to local execution. The main risks are credential access, workflow abuse, persistence on the runner, and unintended reach into internal systems or release infrastructure.

Failure mechanism: An attacker submits or influences workflow-executed code, then uses the runner’s permissions, cached state, environment variables, mounted secrets, or network access to steal tokens, tamper with artifacts, or stage follow-on actions.

Impact: The consequence can be source or artifact compromise, leaked secrets, unauthorized package publication, or a pivot into adjacent systems that were never meant to be reachable from public contributions.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

MITRE ATT&CK address the attack and risk surface, while CIS Controls v8 and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
CIS Controls v86 — Access Control ManagementPublic-repo runners need tight authorization boundaries and least privilege.
12 — Network Infrastructure ManagementRunner isolation depends on limiting network reach from untrusted jobs.
16 — Application Software SecurityWorkflow-triggered code execution must be controlled in the CI/CD software path.
Recommendation — Restrict runner access paths and remove unnecessary privileges from workflow execution. Segment self-hosted runners and block unnecessary outbound and internal network access. Review workflow triggers and execution logic so untrusted code cannot invoke sensitive jobs.
MITRE ATT&CKT1195 — Supply Chain CompromisePublic-repo runners can be abused as a software supply-chain entry point.
Recommendation — Hunt for workflow abuse that can alter build outputs, artifacts, or release paths.
NIST CSF 2.0PR.AC-4 — Access Permissions and AuthorizationsLeast-privilege permissions are central to runner containment.
PR.DS-5 — Data at Rest ProtectionRunner persistence can expose cached secrets and local build data.
DE.CM-8 — Vulnerability and Control DetectionTeams need visibility into unexpected runner behavior and abuse.
Recommendation — Limit workflow and runner permissions so untrusted jobs cannot reach sensitive resources. Protect or eliminate persistent runner data that could be reused by untrusted jobs. Monitor runner activity for abnormal job triggers, network reach, and artifact changes.

Practitioner Guidance

What to prioritise: Treat event routing as the first control, not the last. If a public repository can reach a self-hosted runner by default, assume the trust boundary is already too loose and redesign the trigger path before adding compensating controls.

What to verify: Confirm that untrusted pull requests cannot reach the same runner pool, network segment, or secret-bearing context used for trusted branches. If the runner can survive between jobs, verify exactly what is cleared, rotated, or rebuilt after execution.

Decision rule: If the runner can access secrets, internal services, or publishing systems, it should be treated as sensitive infrastructure and isolated from public contribution paths. If that isolation cannot be proven, move untrusted jobs elsewhere.

Practitioner takeaway: The first security decision is not how to speed up builds, but how to stop public code from inheriting trusted execution conditions.

Deepen Your Knowledge

Sign up to our weekly newsletter — get 33% off our NHI Foundation Level Course

    NHIMG Editorial Note
    Reviewed and updated by the NHIMG editorial team on September 9, 2026.
    NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org