If your build can reach the internet, so can a dependency running inside it. That deserves a deliberate decision when the job handles private source code, customer files, or credentials. Which connections does it actually need, and can you prepare those inputs before the untrusted code runs?
“No egress” needs a boundary and a time period. A container may have no external network interface while its host downloads images and uploads logs. A Kubernetes Pod may be isolated from other Pods while retaining a path to its node. A job may have no network access and still write sensitive data into the artifact you later publish.
Write down the requirement precisely: which workload is isolated, during which phase, and which inputs and outputs remain allowed. Then check the configuration and try the prohibited paths. One failed curl request can’t establish all of that.
Decide which network promise you need
| Requirement | What remains allowed | What it does not mean |
|---|---|---|
| No direct internet access | Potentially internal services, proxies, private endpoints, and DNS | No outbound communication |
| Allowlisted egress | Named destinations or operations through an enforcement point | The permitted destinations cannot carry data out |
| No workload network during execution | Local computation and explicitly permitted non-network inputs/outputs | The host or CI controller is disconnected |
| Air-gapped environment | Only the transfer mechanisms in the environment’s design | That an ordinary hosted CI runner has become air-gapped |
For a hypothetical job that converts an input archive into a report, we would choose no workload network during execution. Prepare its dependencies first, supply only the selected input, and collect a limited result afterward. A deployment job has a different purpose: it needs a narrow connection to the intended deployment service.
GitHub’s self-hosted runner reference describes the runner’s required outbound HTTPS communication. Blocking all traffic from the whole runner host prevents ordinary GitHub coordination. Put the untrusted process behind a separate boundary, or design a disconnected worker and controlled transfer process. Do not describe a connected runner with an isolated child container as an entirely disconnected machine.
Separate preparation, execution, and collection
Give each phase its own identity and writable storage:
- A trusted preparer obtains reviewed tool images, dependency inputs, scan databases, and source files. It records their versions or digests and the time of preparation.
- An isolated worker receives that prepared bundle and runs without deployment credentials or unnecessary network paths.
- A trusted collector retrieves the declared outputs after the worker has stopped. It treats output filenames, archives, reports, and logs as untrusted data.
- A separate promotion process decides which output may leave and where it may go.
Downloading a dependency is not necessarily passive. Package installation may run lifecycle scripts, and a build tool can execute plugins while resolving configuration. If preparation executes contributor-controlled code, it needs containment too. Do not move arbitrary code into a credentialed, internet-connected preparer and call the later phase secure.
Record which commands require a network connection. Preload the actual dependency closure for the workload, including compiler plugins, platform-specific packages, scanner rules, and vulnerability databases. Use the tool’s documented offline mode, then test it under a network restriction. Offline flags help explain failures; the external enforcement point supplies the boundary.
A stale database is an assessment limitation. Set a maximum accepted age for your use case and make missing or expired data visible. Our CI/CD pipeline security guide explains how incomplete assessments should affect promotion.
- PrepareObtain reviewed inputs. Contain any code executed during preparation.
- ExecuteRun the worker without network access or release credentials.
- CollectStop the worker. Inspect declared outputs as untrusted data.
- PromoteApprove a specific artifact and destination before sending it.
A Docker execution pattern with no external network interface
Docker’s none network driver creates only a loopback interface inside the container. This suits a process that needs no network. It does not remove mounted sockets, constrain the Docker daemon’s own network access, or replace host isolation.
The following Linux-container example assumes a trusted controller has prepared two fresh directories, reviewed a job image by digest, and loaded it into the daemon. The image must contain /usr/local/bin/run-job, work as UID/GID 10001, and require writes only to /tmp and /output. Set JOB_IMAGE and a unique JOB_NAME before running it. The output directory must be writable by the intended UID without being shared with another job.
set -euo pipefail
: "${JOB_IMAGE:?Set a reviewed image reference containing @sha256:}"
: "${JOB_NAME:?Set a unique container name for this job}"
case "$JOB_IMAGE" in
*@sha256:*) ;;
*) printf '%s\n' 'A digest-pinned image reference is required' >&2; exit 2 ;;
esac
test -d "$PWD/job-input"
test -d "$PWD/job-output"
docker image inspect "$JOB_IMAGE" >/dev/null
docker run --rm --pull=never --name "$JOB_NAME" \
--network=none \
--read-only \
--cap-drop=ALL \
--security-opt no-new-privileges=true \
--user 10001:10001 \
--pids-limit 128 --memory 512m --cpus 1 \
--tmpfs /tmp:rw,nosuid,nodev,size=64m \
--mount "type=bind,src=$PWD/job-input,dst=/input,readonly" \
--mount "type=bind,src=$PWD/job-output,dst=/output" \
--workdir /tmp \
--entrypoint /usr/local/bin/run-job \
"$JOB_IMAGE"
The digest check above checks the reference’s shape, not its trustworthiness; the image review and distribution verification happen before this command. Docker’s run reference describes the resource, mount, user, and privilege options. Tune the limits for the actual job, including scratch-space requirements.
The controller must reject unexpected mount sources, sockets, device files, and unsafe links in prepared inputs. Do not mount the Docker socket, a cloud credential directory, the controller’s home directory, or a directory used by other jobs. Keep privileged mode and host-network or shared-network-namespace overrides outside the job’s control.
The image is already local, and --pull=never prevents this invocation from fetching it. Earlier image loading and later output upload occur outside the container’s network boundary. If you use docker buildx build --network=none, understand that the documented setting applies to build RUN instructions; review other build activity, such as resolving inputs, separately. See the Buildx network option.
Set a job deadline in the controller. On expiry or cancellation, stop and, if necessary, kill the named container, then check that it is gone. Killing the Docker client process is not a sufficient lifecycle policy. Use a fresh worker VM or another stronger isolation boundary when the threat model requires containment beyond a shared host kernel.
Start Kubernetes network isolation with an explicit policy
The standard Kubernetes NetworkPolicy API needs an enforcing network plugin. Policies are additive: an allow rule in another selecting policy can reopen a path. Creating a default-deny object is therefore the start of the review, not the end. The NetworkPolicy documentation also describes node-traffic exceptions and implementation-dependent behavior for hostNetwork Pods.
In a dedicated test namespace named ci-isolated, this manifest selects every Pod and supplies no ingress or egress allowances:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: isolate-job-network
namespace: ci-isolated
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
ingress: []
egress: []
Apply it only after reviewing the namespace’s intended traffic. It will also deny ordinary Pod DNS traffic covered by the policy. An existing service may stop working, so first exercise the policy in a disposable namespace and build the required acceptance tests.
List every selecting policy, including any CNI-specific policies. Confirm the plugin is enforcing policy on the nodes where jobs can run. For example, Cilium exposes different policy-enforcement modes; the presence of a policy object alone does not describe the complete effective configuration.
This manifest is not a portable proof that a Pod cannot communicate with anything. Review node and metadata paths, host networking, additional interfaces, policy propagation, and protocols outside the plugin’s enforced coverage. Prevent the workload from changing its network policy or requesting privileged networking. For a strict requirement that includes node access, choose and test additional host/network controls or a separate execution boundary.
DNS allowances create an outbound data path
Allowing DNS lets a process send query names to a resolver. If that resolver forwards arbitrary names, a job can place data into those names. An ordinary rule allowing UDP and TCP port 53 to a cluster resolver does not constrain the names being queried.
For an offline execution phase, leave DNS unavailable and preload what the job needs. For an allowlisted phase, decide whether the resolver can enforce a narrow query policy and whether the job can use alternate resolvers or encrypted DNS over another permitted path. Include resolver logs and forwarding behavior in the review.
Domain-based controls require implementation-specific testing. A rule that resolves an allowed domain to IP addresses can have different behavior from an HTTP proxy that checks a destination and request. Neither should be assumed to inspect every use of an allowed connection. Test shared hosting, redirects, connection reuse, and a policy update that changes the allowed addresses.
If a job can reach an approved registry, API, or artifact store, review what it can write there. Read-only identity and resource scoping matter even when the destination itself is trusted.
Cover the paths a single HTTP test misses
Build a small acceptance matrix for the worker, node pool, network plugin, and identity you actually use. Use controlled endpoints and harmless markers. Each denied-path test needs a reachable positive control and a record of the enforcement decision where the platform provides one.
| Path | Test and expected result |
|---|---|
| Direct IPv4 connection | Reach a controlled listener from an approved test source; the isolated job cannot connect to the same listener |
| Direct IPv6 connection | Test the equivalent path where IPv6 is supported; document whether an unavailable address family was tested or merely absent |
| DNS | Attempt a harmless query to the configured resolver and an alternate controlled resolver; compare with the declared DNS policy |
| Internal service | Attempt a connection to a controlled service in another namespace or network segment |
| Node or metadata path | Use provider-approved harmless checks; do not retrieve credentials or sensitive metadata to prove reachability |
| Proxy bypass | Test direct connections without proxy environment variables; disabling a proxy variable must not restore access |
| Allowed endpoint | If exceptions exist, permitted operations succeed and forbidden operations or destinations are denied |
| Restart and rescheduling | Repeat when a worker or Pod is created, restarted, and placed on another eligible node |
| Policy change | Test effective behavior during rollout, not just after the configuration object is stored |
| Output and logs | Harmless canary data reaches only the declared collector and is not published into an unintended artifact or log destination |
Do not interpret “no IPv6 route exists in this test environment” as a tested IPv6 firewall. Similarly, ping is not a substitute for the protocols the workload can use. Preserve the command, source identity, destination, node, time, policy revision, and observed result with each check.
Make a denied connection distinguishable from a broken test
For a controlled TCP listener, this Python probe accepts a numeric address so name resolution is not part of the test. Put it in the reviewed test image or prepared input bundle. Set PROBE_IP and PROBE_PORT to your own listener. Run it once from a permitted test environment, then from the isolated job using the same image and destination.
import ipaddress
import os
import socket
address = str(ipaddress.ip_address(os.environ["PROBE_IP"]))
port = int(os.environ["PROBE_PORT"])
try:
with socket.create_connection((address, port), timeout=3):
print("CONNECTED")
except OSError as error:
print(f"NO_CONNECTION: {type(error).__name__}: {error}")
raise SystemExit(1)
The permitted run should connect, and the isolated run should fail for a reason consistent with the configured boundary. A missing executable, stopped listener, incorrect port, or unrelated routing failure makes the test inconclusive. Pair the result with listener-side observations and firewall, CNI, or proxy evidence where available. A timeout alone does not identify which control caused it.
This probe covers a TCP connection to one address. It does not inspect DNS, UDP, filesystem sockets, artifact upload, or every destination. Keep those as separate cases and rerun them after network, runtime, node-image, or credential changes.
Treat logs and artifacts as deliberate exits
A job can copy readable input into a test report, output archive, filename, exception message, or standard output. A connected controller may then upload that data even though the job could not open a socket.
Decide which files the collector may read, how large they may be, which formats are accepted, and who receives them. Reject path traversal and unsafe archive entries. Parse potentially hostile output in an isolated component, and do not execute an uploaded report as a script. Limit logs and protect their audience and retention.
Do not give the worker more confidential data than its task needs. Output filtering is difficult when arbitrary private input can be transformed into arbitrary output. Some workloads require a human review or a different architecture before results may leave the environment.
Our sandbox-security guide covers filesystem, credential, and lifecycle boundaries alongside network access. The no-egress requirement belongs in that wider review because a local socket or broadly readable credential can defeat the intent of a network-only design.
Evidence to keep with the configuration
Before enabling a private-data job, keep a record of the execution boundary, the permitted input/output paths, the enforcement configuration, and the acceptance results. Include how exceptions are approved, how workers are destroyed, how policy drift is detected, and who can stop a run.
If an operator needs to temporarily restore connectivity to diagnose a failure, use a separate test job with synthetic data. Record the exception and remove it afterward. An emergency allow rule left on the shared runner can affect jobs long after the original debugging session has ended.
Accept the configuration only after the worker completes its intended task, the prohibited connections fail under the test conditions, and the operator has accounted for each permitted output path. Keep the results with the deployed configuration and repeat the affected tests when it changes.
