r/Python • u/shcherbaksergii • Mar 16 '26
Showcase tethered - Runtime network egress control for Python in one function call
What My Project Does
tethered restricts which hosts your Python process can connect to at runtime. It hooks into sys.addaudithook (PEP 578) to intercept socket operations and enforce an allow list before any packet leaves the machine. Zero dependencies, no infrastructure changes.
import tethered
tethered.activate(allow=["*.stripe.com:443", "db.internal:5432"])Hostname wildcards, CIDR ranges, IPv4/IPv6, port filtering
Works with requests, httpx, aiohttp, Django, Flask, FastAPI - anything on Python sockets
Log-only mode, locked mode, fail-open/fail-closed,
on_blockedcallbackThread-safe, async-safe, Python 3.10–3.14
Install: uv add tethered
GitHub: https://github.com/shcherbak-ai/tethered
License: MIT
Target Audience
Teams concerned about supply chain attacks - compromised dependencies can't phone home
AI agent builders - constrain LLM agents to only approved APIs
Anyone wanting test isolation from production endpoints
Backend engineers who want to declare network surface like they declare dependencies
Comparison
Firewalls / egress proxies / service meshes: Require infrastructure teams, admin privileges, and operate at the network level. tethered runs inside your process with one function call.
Egress proxy servers (Squid, Smokescreen): Effective - whether deployed centrally or as sidecars - but add operational complexity, latency, and another service to maintain. tethered is in-process with zero deployment overhead.
seccomp / OS sandboxes: Hard isolation but OS-specific and complex to configure. tethered is complementary - combine both for defense in depth.
tethered fills the gap between no control and a full infrastructure overhaul.
🪁 Check it out!