Lesson 10 of 13 · 18m
Self-Hosted Runners: Your Hardware, Your Threat Model
A self-hosted runner is arbitrary-code-execution-as-a-service on your network — ephemeral pods, runner groups, and egress segmentation make it survivable.
A GitHub-hosted runner is an ephemeral VM in GitHub's fleet that dies when the job ends. A self-hosted runner is a daemon on your hardware that polls GitHub for work and executes whatever the workflow says — arbitrary code, at the privilege of whatever account the service runs as, from your network's position. That inversion — from their sandbox to your infrastructure — is the entire decision.
The warning that is not boilerplate
GitHub's documentation states flatly that self-hosted runners should not be used on public repositories. It's not legal hedging: on a public repo anyone can fork and open a PR, and a workflow triggered by pull_request — or worse, pull_request_target with a head checkout — executes on your machine. The historical outcome is crypto miners and persistence: the runner process runs as a user with your internal network reachability, and an npm install step is all the exploitation anyone needs. There is no sandbox that protects you from the runner; you are the sandbox.
Even on private repos the model differs from hosted. The hosted runner evaporates; the self-hosted runner persists. Work residue — node_modules, build caches, cloned repos, anything a job wrote outside its workspace — survives into the next job unless you clean it or make the runner ephemeral.
The legitimate reasons to run one
- Hardware: GPU builds, ARM targets, big-memory jobs the hosted SKUs don't offer.
- Internal services: the pipeline must reach things that aren't public — a private registry, a test database, a hardware lab.
- Cost at volume: sustained heavy CI can beat hosted pricing, once you count the ops burden you're now paying for.
- Determinism: pinned images, pre-warmed caches, a toolchain that doesn't drift when
ubuntu-latestrepoints to a new OS.
The architecture that makes it survivable
Ephemeral runners. --ephemeral registers a runner for exactly one job then deregisters — every job gets a fresh process and, with a container-per-job setup, a fresh filesystem. actions-runner-controller (ARC) runs this on Kubernetes: an autoscaler that spins a runner pod per queued job and destroys it after, scaling on queued-run count rather than CPU. Jobs target specific hardware through label syntax — runs-on: [self-hosted, linux, gpu] — so a GPU job never lands on the general pool. Ephemeral is the difference between "a compromised job owns a build server" and "a compromised job owns a pod with a ten-minute lifespan."
Runner groups. Runner groups scope which repositories may dispatch to which runners — the payments repo's runners shouldn't be reachable by the marketing site's workflows.
Network segmentation. The runner's egress defines your blast radius. A runner that can reach production subnets, the cloud metadata service, or the internal admin panel turns every repo it serves into a lateral-movement path. Put runners on a segment that reaches GitHub and the registries they need — and nothing else.
Token hygiene. The registration token is short-lived; the runner's configured credentials keep it taking work. Ephemeral plus just-in-time registration via the API beats long-lived PATs sitting in provision scripts.
Field notes
- Docker-in-Docker on a runner usually means mounting
/var/run/docker.sock— which is root on the host in everything but name. Rootless DinD or isolated build nodes are the fix. - Hosted runners get patched by GitHub; self-hosted runners get patched by you. The runner binary auto-updates; the OS does not.
- If a self-hosted runner runs on the same host as anything it could hurt, the runner is the thing the attacker was looking for.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Your npm Install Just Ran Someone Else's Code: Why Dependency Security Has to Start Before CI
A pull request checkout, a poisoned GitHub Actions cache, and an OIDC token pulled straight out of runner memory. That's how 84 malicious versions of TanStack's packages hit npm in six minutes.
What is Supply Chain Security? Dependencies, SBOMs, and the Attack That Hit 2.6 Billion npm Downloads
Your application is only as secure as every package it depends on. In September 2025, attackers compromised 27 npm packages with 2.6 billion weekly downloads by phishing one maintainer.
Zero Trust Everything: The Complete Guide to Self-Hosting Teleport for Secure Infrastructure Access
SudoSecurity runs Teleport internally for everything — admin panel access, secure database connections, Kubernetes, and zero-trust philosophy across our entire team. This is the complete technical guide to installing, configuring, and running your own self-hosted Teleport cluster from scratch.
Lockfiles and Dependency Audits in Composer, uv and npm: What Each One Actually Pins, Checks and Refuses
I built the same deliberately outdated project in Composer, uv and npm, then audited, tampered with and drifted each lockfile. Composer now refuses to resolve vulnerable versions at all, uv and npm both caught a single changed hash, and Composer's lockfile recorded no hash for any of its seven...