Isolate CI runners from an internal Git platform

Separate CI execution from Git hosting with runner trust zones, short-lived credentials, network restrictions and synthetic cross-job isolation tests.

Last updated

In short

  • Treat every CI job as code execution with a defined trust level.
  • Keep untrusted builds away from deployment credentials and production networks.
  • Ephemeral execution reduces persistence but does not replace network controls.
On this page (6)

Architectures · Part of GitLab

Put build execution in a separate trust zone

A private Git server stores source code and coordinates development. A CI runner executes commands chosen by repository content. Those are different security responsibilities. Placing a runner beside the Git database or giving every build access to a production network turns a repository change into a much broader operational capability.

This is a reference isolation design and a synthetic acceptance exercise. It is not a penetration-test result or a claim that a particular executor has been validated. Both GitLab’s runner security guide and Forgejo’s Actions security guidance treat build execution as a boundary requiring deliberate controls.

Classify jobs by trust

Job class Example Credentials allowed Network reach
Untrusted contribution External pull or merge request Minimal read access needed for the test Approved dependency mirrors and test endpoints
Internal validation Reviewed branch test suite Narrow test-service credentials Isolated development services
Release build Protected release ref Artifact-signing capability under policy Approved registry and signing service
Production deployment Approved deployment job Short-lived scoped deployment credential Specific deployment control endpoint

A job label or runner tag is a scheduling control, not necessarily a complete isolation mechanism. Confirm who can select the runner, change pipeline definitions and trigger protected jobs. A broadly privileged person in the Git platform may be able to change those controls, so document the administrative boundary as well.

Do not allow untrusted contributions to choose a privileged runner through editable workflow configuration. Separate runner pools and registration scopes where the platform supports them, and review how forked contributions receive secrets in the selected version.

Choose an executor with known consequences

Execution choice Main benefit Boundary requiring verification
Shell on persistent host Simple access to local tools Jobs can leave files and processes for later jobs
Container per job Repeatable environment Host mounts, container privileges and daemon access
Ephemeral virtual machine Fresh host boundary for each workload Image provenance, cleanup and cloud credentials
Dedicated release environment Restricted signing and deployment path Who can submit code and approve execution

A container with the host’s container-engine socket can often control far more than its own filesystem. Privileged execution and host mounts should be exceptional and isolated to a trust level that justifies them. Where a build needs to produce a container image, select and evaluate a build mechanism instead of automatically exposing the host daemon.

Pin the Git platform, runner, executor and base-image versions. The runner and server may have a documented compatibility policy; verify it before independently upgrading one side. Commercial platform features, hosted-runner minutes and advanced approval controls can have separate edition requirements.

Design the secret path

Prefer credentials that are scoped to one task and expire quickly. A repository checkout token should not also administer the Git platform. A test database password should not work against production. A deployment credential should be available only in the intended protected job context.

Masking a variable in logs is useful but cannot prevent a malicious job from transmitting the secret elsewhere. Limit egress, minimize secret availability and inspect the code that receives the credential. Keep signing keys outside the general build environment when the release process permits a separate signing step.

Caches and artifacts are another cross-job boundary. A cache produced by an untrusted contribution should not silently become an executable dependency in a privileged release. Define cache keys, ownership and trust transitions explicitly. Verify artifact digests before promoting them between stages.

Run synthetic negative tests

Create a harmless test repository with no real deployment credentials. Use synthetic marker files and tokens to check the boundary.

Test Expected outcome Evidence
Read another job’s workspace Denied or absent Job output and executor lifecycle
Contact a private production address Denied Network policy observation
Request a protected release runner from an untrusted ref Not scheduled Platform scheduling record
Read a secret reserved for release Unavailable Sanitized environment inspection
Persist a marker into the next job Marker absent Fresh execution environment record
Fetch an unapproved dependency host Denied under the chosen policy Egress log

These checks should use controlled targets and synthetic values. A successful negative test demonstrates that particular boundary in that configuration; it does not prove that arbitrary malicious code cannot escape every layer.

Recover by replacing compromised execution state

Treat a suspected runner compromise as an incident affecting credentials and artifacts it could access. Stop scheduling work on it, preserve the necessary evidence and replace the execution environment from a reviewed image. Rotate exposed credentials and inspect outputs produced during the affected period before releasing them.

Back up runner configuration, image definitions and registration procedures rather than relying on a snapshot of a mutable job workspace. Keep Git repositories and platform state under their own backup plan. Recovery should not restore a potentially compromised runner image merely because it starts quickly.

For rollout, introduce the new pool with synthetic jobs, then a limited internal workload, then the intended release class. Keep a controlled previous configuration for scheduling rollback, but do not fall back to a less isolated pool without an explicit operational decision. Acceptance means each trust class can do its required work while the negative tests demonstrate that broader access is unavailable.

Sources and further reading

Use the linked documentation to confirm the version, edition and contract that apply to your project.

Review our build environment

Bring pipeline trust classes, executor choices, signing requirements and the networks builds must reach.