terok-shield
Default-deny egress firewall for rootless Podman containers.
terok-shield enforces default-deny outbound network filtering on Podman containers using nftables. Containers can only reach explicitly allowed destinations — everything else is rejected with an ICMP error and a per-packet audit entry.
Where it sits in the stack
terok-shield is the firewall layer of the terok ecosystem. The hardened-Podman runtime (terok-sandbox) installs the OCI hooks at setup time; the operator-in-the-loop verdict service (terok-clearance) mutates the live ruleset on Allow / Deny decisions. The shield itself is independent of all of these — it works on any rootless Podman container, with or without the rest of terok.
Features
- Default-deny egress with curated allowlists (domains and IPs)
- Dynamic DNS allowlisting — per-container dnsmasq with
--nftsetauto-populates allow sets on every DNS resolution, handling IP rotation at runtime; degrades to resolution at launch when dnsmasq lacks nftset support or is unavailable, and says so - Live allow/deny at runtime for individual containers
- Per-container isolation — each container gets its own state bundle and audit log
- Connection audit logging (JSON-lines lifecycle logs + kernel-level per-packet nftables logs)
- Fail-closed — hook failure prevents the container from starting
Requirements
- Linux with nftables (
nftbinary) — tested on Fedora 43, Debian 12 and 13, and Ubuntu 24.04, also works on other modern Linux distros - Podman (rootless, recommended ≥ 5.6.0, untested < 4.3.1)
- Python 3.12+
dnsmasq(recommended) for dynamic DNS-based egress control;dig(dnsutils/bind-utils) as fallback
Installation
pip install terok-shield
Quick start
1. Choose your allowlists
terok-shield ships with several bundled profiles (see Allowlist Profiles):
| Profile | Domains |
|---|---|
base |
DNS roots, NTP, OCSP, OS package repos |
dev-standard |
GitHub, Docker Hub, PyPI, npm, crates.io, Go |
dev-python |
Conda, Read the Docs, Python docs |
dev-node |
Yarn, jsDelivr, unpkg |
nvidia-hpc |
CUDA, NGC, NVIDIA drivers |
No profile applies unless you name one. To add a custom allowlist,
create a .txt file in ~/.config/terok/shield/profiles with one
+-prefixed (allow) or --prefixed (deny) entry per line — a domain,
an IP or CIDR, optionally :port — or +localhost:PORT to reach a
service on the host's own loopback (as host.containers.internal:PORT
inside the container):
e.g. ~/.config/terok/shield/profiles/my-project.txt
+api.example.com
+cdn.example.com
+203.0.113.10
+localhost:9931
2. Start a container with the shield
terok-shield setup
terok-shield run my-container --profiles dev-standard -- alpine:latest sh
Setup installs global OCI hooks; run resolves DNS and launches the container
with a default-deny firewall — only destinations in the
dev-standard profile are reachable. To use custom profiles:
terok-shield run my-container --profiles dev-standard,my-project -- alpine:latest sh
To see — or apply by hand — the ruleset those profiles produce, without setup, podman or any state:
terok-shield preview --profiles dev-standard,my-project > rules.nft
3. Allow a domain at runtime
terok-shield allow my-container example.com
# Allowed example.com -> <resolved-ip> for my-container
terok-shield deny my-container example.com # revoke later
License
Apache-2.0 — see LICENSES/Apache-2.0.txt.
Metadata
Release files for terok-shield 0.10.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| terok_shield-0.10.0.tar.gz | 622.7 kB | With provenance | Details for terok_shield-0.10.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| terok_shield-0.10.0-py3-none-any.whl | Python 3 | none | any | Details for terok_shield-0.10.0-py3-none-any.whl |
Total release size: 857.4 kB
Release files / terok_shield-0.10.0.tar.gz
| Download URL | terok_shield-0.10.0.tar.gz |
|---|---|
| Size | 622.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0bc81cbc9a728c93f305af48f60d2e49333cf7a6b3b0ff80c5f5814366d93a64
|
|
BLAKE2b-256 checksum How to use checksums |
c4c9c7f82def19d580c2c73ff07bfa82c59768ad92a8ea563c8e2584579ee9f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.
Transparency logRelease files / terok_shield-0.10.0-py3-none-any.whl
| Download URL | terok_shield-0.10.0-py3-none-any.whl |
|---|---|
| Size | 234.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3657c4fb8cf2edc5fdccdcb32ba81a032c9822986332371c8a20546c229d3ca9
|
|
BLAKE2b-256 checksum How to use checksums |
7001505cc5450ef6d75813aa3666b1ce97df8e1ed756b371446f6e9c8e630e52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.
Transparency logSecurity for terok-shield 0.10.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for terok_shield-0.10.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 17, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.