A CI/CD job executes repository code with the access its environment provides. That code includes build scripts, test tools, dependencies, and pipeline changes. Even an ordinary test job can read credentials, change files, or contact other systems if its runner permits those actions.
Arrange execution around the consequences of running that code. A contribution that hasn't been reviewed needs a different environment from a job that signs a release or deploys to production. Keeping those jobs apart limits how far a compromised or mistaken job can reach.
Separate job selection from execution isolation
Runner scope determines which projects can use a runner. Tags match jobs to runners with the needed capabilities, and protected status restricts eligible refs. These settings help select where a job runs; the executor, host, credentials, and network determine what it can do once it starts.
For example, a runner tagged production doesn't become a protected deployment service merely because of its name. A project that can use it may request that tag. Likewise, two runner registrations on the same reused host can leave jobs exposed to one another's files or processes. Examine the underlying resources as well as their labels.
Keep fork and untrusted merge request work separate from protected builds, signing, and deployment work. When allowing merge request pipelines to access protected variables and runners, GitLab requires both branches to be protected, both branches to belong to the same project, and the triggering user to have push or merge access to the target branch. Targeting a protected branch alone isn't enough.
Fork merge request pipelines can't access those protected resources. However, a project member can run a fork's pipeline in the parent project, where it uses the fork's configuration and the parent's available resources and unprotected variables. Review that code before triggering it, and check that the available runner pool is suitable for untrusted work.
Contain the work a job can perform
Fresh execution environments reduce the chance that one job leaves code or data for the next. With the Instance executor, setting both capacity_per_instance and max_use_count to 1 gives each job its own disposable instance. Reusing instances or allowing several jobs per instance changes that isolation. GitLab-hosted runners on GitLab.com also use a dedicated temporary VM for each job.
An ephemeral host can still reach an overly broad network or use excessive cloud permissions during its lifetime. Restrict access to the services the job needs, and give deployment pools access only to their intended targets. Keep caches and stored artifacts from becoming an indirect path between untrusted work and protected jobs.
Shell jobs run with the runner user's host permissions. Privileged containers can gain extensive host access. Reserve such execution for workloads you trust, with dedicated infrastructure and a disposal strategy appropriate to that access. Running the runner manager inside a container doesn't by itself isolate the jobs it launches.
Protect runner managers, authentication tokens, and configuration files. Keep managers away from the GitLab server and other critical systems, and limit who can change their configuration. A stolen runner token can let an attacker impersonate a runner, so token protection is part of protecting the jobs assigned to it.
Balance capacity with the separation you need
Separate pools and disposable hosts cost more and reduce cache reuse. Idle capacity can reduce start times, while on-demand provisioning saves idle cost but adds delay and can fail under capacity constraints. Measure queue time, provisioning time, utilization, failures, and peak demand before adjusting concurrency or pool size.
CPU, memory, and disk limits help keep one workload from exhausting shared capacity. Patching, cleanup, and compatible Runner upgrades need an owner alongside scaling decisions. The Instance and Docker Autoscaler executors support autoscaling; a fleet still using the deprecated Docker Machine executor needs a migration path.
Choose hosting around access and operating responsibility as well as cost. Self-managed runners give your team responsibility for their hosts and configuration. GitLab Dedicated also offers hosted runners through your account team. In either case, confirm the trust, network, and credential separation your workload requires.
Runner separation by workload trust explains how to trace existing jobs, choose pools, and test that unwanted access is denied. If jobs still take too long after they start, improving pipeline feedback can help identify delays that more runner capacity won't solve.
Further Reading
- Understand executor and host risks explains how privileges, host reuse, and shared resources affect job isolation.
- Configure runner selection and protection covers scope-related controls, tags, protected runners, and token management.
- Review merge request and fork pipeline access explains when parent-project and protected resources become available.
- Plan autoscaling runners and configure the Instance executor explain capacity, instance reuse, and executor choices.
- Monitor runner performance helps distinguish a capacity problem from job or infrastructure failures.
- Compare GitLab.com hosted runners and GitLab Dedicated hosted runners when deciding who will operate the fleet.