Skip to content

Egress control

github-actions[bot] edited this page Nov 14, 2026 · 7 revisions

Egress control

Egress is outbound network traffic from the runner. Controlling it limits where a compromised step, dependency or action can send data. Full reference: README: Egress.

harden-runner on every job

step-security/harden-runner is the first step of every job (a test checks), so the policy is in place before anything else runs. The one exception is the egress policy check (below): it runs before harden-runner, touches no network, and fails the job if a policy value is not exactly audit or block.

Mode Behaviour Used for
audit Logs every outbound connection to the job summary; blocks nothing The default of egress-policy, and how a list is measured
block Refuses any host not in allowed-endpoints Every adopted repository; the default of egress-policy-secretless

Turning it on in a caller is one line:

with:
  egress-policy: block

Known platform issue: westus2 (EX-0001), closed

Closed on 2026-11-02. GitHub-hosted runners in westus2 broke block (a DNS experiment made the agent drop allowed IPs), and from 2026-10-24 jobs that hold no secret followed the egress-policy-secretless input with a default of audit. A 600-job experiment on harden-runner v2.22.3 (150 jobs per arm over 3 runs) passed block on 15 of 15 westus2 jobs and 135 of 135 on other regions, while the control (block on v2.22.2) passed 137 of 137 on other regions and failed 13 of 13 on westus2. The default is block again, and the pip and buildx caches are back in those jobs (they are on whenever a job's effective policy is block). Caveats: the root cause is not shown, only the symptom is gone with v2.22.3, and two control arms hit westus2 only 5 and 8 times (145 and 142 ok on other regions).

If it recurs, a caller sets egress-policy-secretless: audit on the workflow call. The fail-fast egress canary that once sat in every block job was removed on 2026-11-14 (#412): it outlived the exception and failed a real run on a runner with bad DNS. tests/test_egress_policy.py keeps it out. The scope, the evidence, the closure and the history are in EX-0001. Full description: README.

Where the lists come from

Each workflow carries a measured allow-list as the default of allowed-endpoints: every host its jobs reached across the calling repositories in a day of audit-mode runs. The runner's own infrastructure is left out because the agent allows it itself. Some lists (bash-ci.yml, distro-allowed-endpoints, semgrep-allowed-endpoints, verify-published.yml) were measured the other way round: this repository runs them on itself in block mode, so a missing host fails here, named in the log, before any caller meets it.

A host only one repository reaches (an apt repository, an installer its Dockerfile pulls) goes in that caller's extra-allowed-endpoints, never in the shared default.

Reading a block

A blocked connection shows up in the job log as:

domain not allowed: <host>

That is also how a new dependency announces itself: your build started talking to something new. Decide whether that is expected; if so add the host to extra-allowed-endpoints.

Gotchas (each cost real time)

  • The allow-list is ONE space-separated line. A YAML literal block (|) keeps newlines, the agent matches nothing and blocks everything, including PyPI. Use one line or a folded block (>).
  • No wildcards. *.example.com is not supported and invalidates the whole list.
  • Format is host:port, sorted. A test holds every default to this.
  • Fedora/dnf can't be listed. dnf takes its mirror from a metalink answer that differs per run, so no fixed host list stays green. Use distro-egress-policy: audit for those images, or add the mirrors you observed.
  • Kali and Parrot are pinned, because their official redirectors answer each request with a different mirror. The default distro-setup-command rewrites the sources to a single stable host. A custom setup command loses that.
  • Snyk's hosts came from its docs, because the first run's connections were logged as IP addresses only. Every Snyk-enabled repository has since run green under block, which is the measurement.
  • Containers a job starts are outside harden-runner's view. The distro job runs an official image as root in a throwaway container, sharing the job's network namespace, so the egress block still applies. StepSecurity's "unmonitored container" finding on those jobs is accepted for that reason.

Related: disable-sudo

Every harden-runner step sets disable-sudo: true, so a compromised step cannot become root. The only exceptions are jobs that run a caller's own install command (which may legitimately say sudo apt-get install ...).

Clone this wiki locally