A GitHub Action for egress filtering and runner lockdown.
Add Fence as the first step in a GitHub-hosted Linux job:
jobs:
test:
runs-on: ubuntu-24.04
steps:
- uses: openai/fence@<commit-sha> # pin@vX.Y.Z
- uses: actions/checkout@<checkout-commit-sha>
- run: script/testCopy the full commit SHA and version comment from the latest verified release. Fence supports GitHub-hosted x64 runners on ubuntu-24.04, ubuntu-26.04, or ubuntu-latest. The scheduled canaries run the published pin before checkout in block and audit on all three labels. If Fence stops working on an unchanged workflow, check current and resolved runner compatibility issues.
By default, Fence:
- Blocks outbound connections unless the hosted runner needs them or you allow them.
- Turns off passwordless
sudo. - Turns off Docker and container access.
- Reports network activity in the job summary and logs.
See Getting started for a complete example.
Add destinations your workflow needs to the allowlist:
- uses: openai/fence@<commit-sha> # pin@vX.Y.Z
with:
allowlist: |
api.example.com
registry.example.com:8443
udp://dns.example.com:53
ip 192.0.2.10 tcp 443
cidr 192.0.2.0/24 udp 123Bare hostnames default to TCP port 443. Fence also supports IPv6, custom ports, TCP, UDP, CIDR ranges, and one- or two-level hostname wildcards. An allowlist can contain up to 64 unique entries.
Allowlist the hostname, not every IP address it might use. In block mode, Fence refreshes exact hostnames in the background, verifies the firewall rules before returning a new address, and can shorten DNS cache lifetimes to match. If the policy fills up, Fence refuses new addresses and still removes expired ones.
See allowlist syntax for all supported formats.
Not sure what your workflow needs? Start with audit mode:
- uses: openai/fence@<commit-sha> # pin@vX.Y.Z
with:
mode: auditAudit mode shows what Fence would block while leaving network, sudo, and Docker access available. For example, if DNS requests exceed the user wildcard hostname limit, audit forwards them and reports what block mode would deny. It may still restore root ownership of /etc and /usr. Use the job summary to build your allowlist, then switch back to block mode.
On Ubuntu 26.04, the system manager can hold several listeners for the same socket name. Fence verifies the owner and tracks each backing file. Both block modes restrict every file, including ones without a name. Audit checks the original permissions without changing them. This layout requires the image's verified Perl executable and kernel support for obtaining the file handles. If Fence can't verify the whole group, startup fails. Look for socket_check and socket_detail in the Actions error or post hook. The troubleshooting guide explains these labels.
When the Ubuntu ACPI event socket is present, Fence verifies its two owners, systemd and acpid. Both block modes deny the workflow access to the socket. Audit preserves access. A change to either owner fails verification.
On supported runners, Fence accepts normal Ubuntu UUID service activation (for example, by az version) in audit and block modes. Fence checks socket access in batches to reduce the work on busy runners. Incomplete checks or unexpected owners still fail the job. The troubleshooting guide explains how to distinguish a timeout from a failed ownership check at startup or during the job.
Artifact uploads, GitHub Pages, and caches sometimes need access to storage endpoints used by GitHub Actions:
- uses: openai/fence@<commit-sha> # pin@vX.Y.Z
with:
allow_github_artifacts: trueImportant
This setting gives the job another way to send data off the runner. It is off by default; turn it on only when the job needs artifacts, Pages, or caches.
When Fence needs to verify which process requested a storage endpoint, it asks the host resolver to retry over TCP. DNS clients that only support UDP can't resolve those names in block mode.
Fence disables Docker by default. If your job needs containers, you can keep it available:
- uses: openai/fence@<commit-sha> # pin@vX.Y.Z
with:
container_policy: unsafe_preserveWarning
Keeping Docker gives up containment. Later steps can use Docker to gain root access and bypass Fence's network rules.
Run Fence once per job. If setup fails, start with that error, even if the post-job step also fails. Fence won't guess whether protection started or cleanup succeeded, and it never undoes the lockdown after reporting ready.
Fence runs before the rest of your job and controls which network destinations the runner can reach:
- It checks that the runner and bundled agent are supported. You don't need to change
/etc/resolv.confif the runner provides it as a regular file instead of a symlink. - It allows required GitHub and runner connections, plus your
allowlist. - It blocks other outbound connections and turns off passwordless
sudoand Docker. - It checks that the firewall is active, not just that its rules exist, before reporting readiness and throughout the job.
- At job end, it verifies that readiness was committed and its protections are still healthy, reports network activity, and fails the job if they changed unexpectedly.
See how Fence works for more detail.
Fence can start when /run is mounted with noexec. It keeps its verified executable in a separate root-owned directory and leaves the mount restrictions in place.
During startup, Fence can retry its read-only Docker check once if the command times out silently. The job proceeds only after Fence verifies the requested container policy.
Fence checks listening services without counting unrelated TCP connections against the inspection limit. At startup, it can check again if a known socket has no visible owner. If it still can't verify ownership, it stops. The setup error can identify an ownership gap, a mismatch with the expected inventory, or a restricted listener that still appeared reachable. See troubleshooting.
If Fence can't verify the runner's local services during a job, the post-job diagnostic can show what the first failed check saw. The job still fails.
After evidence validation, Fence writes a network activity table and a FENCE_REPORT_JSON= line to the post-job log. It also adds the activity table to the job summary when available. You can fetch the report through the GitHub API:
gh api repos/OWNER/REPO/actions/runs/RUN_ID/jobs \
--jq '.jobs[] | {id, name}'
gh api repos/OWNER/REPO/actions/jobs/JOB_ID/logs \
| sed -n 's/^.*FENCE_REPORT_JSON=//p' \
| jq .The report shows network activity and warnings. In audit mode, it lists DNS names and connection IPs separately and suggests allowlist entries. You'll still see the activity when an allowlist entry can't grant access. A recent DNS match can help Fence avoid suggesting an unnecessary IP entry; it doesn't prove what block mode would allow. Some activity may be missing, and a DNS warning can mean Fence safely refused an answer. Anyone who can read the job log can read the report.
Fence counts DNS lookups for names that look like IP addresses under Other DNS names. That means a DNS query was observed, not a connection to that IP address.
See Network reports for an example.
Fence makes it harder for later workflow steps to send data to unexpected destinations or undo the runner's network restrictions. It is not a full sandbox.
- Supported runners are GitHub-hosted x64 jobs using
ubuntu-24.04,ubuntu-26.04, orubuntu-lateston reviewed Azure and AWS hosts. An Ubuntu label does not identify the cloud. If Fence cannot identify the platform, including on GCP, it stops before readiness. - Snap service: Fence can start while Ubuntu's Snap daemon is active. It checks that systemd still owns each reviewed listener and verifies the identity of the service sharing it.
- DNS uses one fixed resolver for the detected cloud. Block and audit both check that it can resolve a required GitHub Actions name and ignore replies from any other IP address or port. Fence never tries another cloud's resolver or adopts a DNS server from the job. The VM's own short hostname can resolve locally to loopback without opening network access.
- UDP: Block mode stops outgoing packets when their allowance ends, even from the same source port. Audit mode reports those packets without blocking them. Replies to allowed requests still work.
- Azure needs two platform services. In block mode, only root-owned host sockets can reach WireServer. Azure instance metadata remains reachable at
169.254.169.254:80. - AWS has no Azure service permissions. Block mode denies EC2 instance metadata to host and forwarded traffic, even under an overlapping allowlist entry. Audit records attempted access without blocking it.
- Artifacts:
allow_github_artifacts: trueallows limited access to storage used by GitHub Actions. - Docker: Fence disables Docker without changing its DNS settings. If you keep Docker available, later steps can bypass Fence.
- Release pinning: Copy the full commit SHA from the verified release notes, not from
mainor a version tag.
See the security guide for more details.
See Local development for build and test instructions. Hosted CI allows a bounded wait for complete blocked-event evidence without changing enforcement or the protected-finalization deadline.
- Getting started
- Configuration examples
- Allowlist syntax
- How Fence works
- Security guide
- Troubleshooting
- Release provenance
- CLI reference
- Security policy
- Fence v0 specification
- Threat model
- Security review
- Implementation history
- Repository settings
- Hermetic builds
Fence is released under the MIT License.
