GitHub-hosted vs self-hosted runners: when self-hosted is safe

Verdict: Never attach self-hosted runners to a public repository. Any fork can open a pull request that runs untrusted code on a machine that persists state between jobs. Keep self-hosted runners on private repositories only.

CriterionGitHub-hosted runnersSelf-hosted runners
Public repo safetyEphemeral clean VM per job; safe for fork pull requestsAlmost never use; a fork PR can run untrusted code and persistently compromise the machine
IsolationFresh VM discarded after each jobState can persist between jobs unless the runner is ephemeral
Architecture supportStandard hosted setARM64 on Linux, macOS and Windows; ARM32 on Linux only
Behind an IP allow listToo many frequently changing IP ranges to allowlistAdd the runner IP range to the enterprise allow list
When hosted runners are disabledEnterprise can disable standard hosted runnersJobs must then target an approved runner group

Rules

Traps