{"id":51224779,"url":"https://github.com/saagpatel/cross-provider-egress-guard","last_synced_at":"2026-06-28T10:03:10.259Z","repository":{"id":366218669,"uuid":"1275161265","full_name":"saagpatel/cross-provider-egress-guard","owner":"saagpatel","description":"Destination-aware, default-deny egress control for AI coding agents, at the tool-dispatch layer across Claude Code and Codex from one shared policy.","archived":false,"fork":false,"pushed_at":"2026-06-20T19:02:55.000Z","size":244,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-20T21:04:34.857Z","etag":null,"topics":["agent-security","ai-agents","ai-safety","claude-code","codex","data-exfiltration","default-deny","devsecops","egress-filtering","hooks","llm-security","mcp","model-context-protocol","prompt-injection","security-tools"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saagpatel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-20T10:30:55.000Z","updated_at":"2026-06-20T18:39:16.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/saagpatel/cross-provider-egress-guard","commit_stats":null,"previous_names":["saagpatel/cross-provider-egress-guard"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/saagpatel/cross-provider-egress-guard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saagpatel%2Fcross-provider-egress-guard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saagpatel%2Fcross-provider-egress-guard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saagpatel%2Fcross-provider-egress-guard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saagpatel%2Fcross-provider-egress-guard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saagpatel","download_url":"https://codeload.github.com/saagpatel/cross-provider-egress-guard/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saagpatel%2Fcross-provider-egress-guard/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34884278,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-28T02:00:05.809Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agent-security","ai-agents","ai-safety","claude-code","codex","data-exfiltration","default-deny","devsecops","egress-filtering","hooks","llm-security","mcp","model-context-protocol","prompt-injection","security-tools"],"created_at":"2026-06-28T10:03:09.556Z","updated_at":"2026-06-28T10:03:10.252Z","avatar_url":"https://github.com/saagpatel.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cross-provider-egress-guard\n\n**Destination-aware, default-deny egress control for AI coding agents, enforced at the\nagent's own tool-dispatch boundary, across both Claude Code and Codex.**\n\n[![CI](https://github.com/saagpatel/cross-provider-egress-guard/actions/workflows/ci.yml/badge.svg)](https://github.com/saagpatel/cross-provider-egress-guard/actions/workflows/ci.yml)\n[![Release](https://img.shields.io/github/v/release/saagpatel/cross-provider-egress-guard)](https://github.com/saagpatel/cross-provider-egress-guard/releases/latest)\n[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)\n\n\u003e A default-deny firewall for your coding agent's tool calls: a hijacked or prompt-injected\n\u003e agent can't ship your data to a host you didn't allow-list, and the **same policy covers\n\u003e both Claude Code and Codex**.\n\n![The egress guard denying exfiltration attempts in a terminal: an attacker host, a userinfo-spoofed github.com@evil.tld, an unknown connector, and an arbitrary http_post tool are all denied; a legitimate github.com call is allowed; and the guard fails closed when the policy is missing](demo/egress-guard.gif)\n\n*Six representative tool calls against the example policy. Reproduce it offline with `bash demo/demo.sh`.*\n\n---\n\n## The threat\n\nAn AI coding agent holds broad capability: it reads your files, calls tools, and reaches the\nnetwork through MCP connectors and the shell. A single hostile instruction (whether the\nmodel goes off the rails or a **prompt-injection payload rides in tool output**) can turn\ninto one tool call that ships data to an attacker-controlled host. Most agent setups have\n**no destination control** on that call: if the agent can name a URL, it can reach it.\n\nThis guard closes that: **network/send-class tool calls and shell network commands are denied\nby default unless their destination is on an allow-list you control.**\n\n## What it is\n\nA small set of **PreToolUse hooks** (Claude Code) and an equivalent **hook patch** (Codex)\nthat classify every tool call and gate the network-shaped ones against one shared JSON\nallow-list policy. It runs *inside the agent's own dispatch cycle* (no network\nreconfiguration, no proxy to stand up, no per-app SDK changes) and enforces the **same\npolicy across both agents** from a single source of truth.\n\n- **Default-deny** for network/send-class tools; everything else is unaffected.\n- **Per-destination** host allow-listing and **per-connector** scoping (including resource\n  owner scoping, e.g. only your GitHub org).\n- **Fail-closed**: a missing, unreadable, or invalid policy denies; it never falls open.\n- **Cross-provider**: Claude Code (`mcp-guard.sh` + `bash-egress-guard.sh`) and Codex\n  (`codex-egress.patch`) read the *same* `mcp-gate-policy.json`, so the two agents can't drift\n  to different blast radii.\n\n## Where it sits (honest positioning)\n\nAgent egress can be controlled at two layers, and they are **complementary**:\n\n- **Network-proxy layer**: a forward proxy / firewall / DLP outside the agent (e.g.\n  [Pipelock](https://github.com/luckyPipewrench/pipelock), Promptfoo's MCP proxy, MCP\n  gateways). Independent of the agent; strong, but needs network plumbing and lives outside\n  the agent's semantics.\n- **Agent hook layer**: *this project*. Gates each tool call **before dispatch**, with\n  per-tool/per-connector/per-owner semantics, with no network reconfiguration.\n\nNothing published (as of mid-2026) does default-deny, per-destination egress control at the\n**hook layer, cross-provider across Claude Code *and* Codex**, off one shared policy. That's\nthe gap this fills. For real defense in depth, run **both** layers; see\n[LIMITATIONS.md](LIMITATIONS.md) on why an in-process hook is not a substitute for a network\nchoke point.\n\n## How it works\n\nA tool call is classified into exactly one mode (checked in order):\n\n1. **URL-host**: tools carrying an explicit URL (browser navigate, fetch). Allowed iff every\n   extracted host ∈ `allow_hosts`. Deceptive hosts (userinfo-spoof, trailing-dot, punycode,\n   IP-literal) are normalized to their true host first; no extractable host ⇒ deny.\n2. **Connector-class**: fixed-backend connectors with no URL in the payload. Allowed iff the\n   full tool name matches an `allow_connectors` glob; unknown/renamed connector ⇒ deny.\n   Optional `connector_owner_scope` further restricts a connector to allow-listed resource\n   owners.\n3. **Generic-network catch-all**: any tool whose *name* signals network/send behavior but\n   matches neither mode above ⇒ **fail-closed deny** unless its server is local\n   (`non_egress_servers`).\n4. **Unknown tool carrying a `scheme://host` payload** ⇒ fail-closed deny.\n\nThe shell hook (`bash-egress-guard.sh`, and the Codex side) applies the same allow-list to\n`curl`/`wget`/`ssh` and owner/host-scopes `git push` / `gh` **writes** (reads are never\ngated). Full model: [docs/THREAT-MODEL.md](docs/THREAT-MODEL.md) and\n[docs/DESIGN.md](docs/DESIGN.md). Mapped to the\n[OWASP Top 10 for LLM Applications (2025)](docs/OWASP-LLM-MAPPING.md).\n\n## Quickstart\n\nNo install required — runs entirely offline against the in-repo hooks:\n\n```bash\ngit clone https://github.com/saagpatel/cross-provider-egress-guard\ncd cross-provider-egress-guard\nbash tests/run-all.sh        # runs the full deterministic suite against the in-repo hooks\n```\n\nYou'll watch egress denies fire across every mode (navigation to a non-allow-listed host,\nunknown connectors, deceptive GitHub hosts, oversized novel-host payloads) and legitimate\nallow-listed calls pass. Requires only `bash` and `jq` (preinstalled on macOS/Linux).\nThis same suite (200+ assertions across both agents' enforcement, plus a cross-provider\nparity check proving they read one shared policy) is the CI gate.\n\n## Install\n\nQuick deploy (three steps):\n1. Copy `policy/mcp-gate-policy.example.json` to `~/.claude/mcp-gate-policy.json` and set your `allow_hosts`, `allow_connectors`, and owner values.\n2. Copy `claude-code/hooks/lib/deny.sh` to `~/.claude/hooks/lib/` and `claude-code/hooks/*.sh` to `~/.claude/hooks/` (CC); apply `codex/codex-egress.patch` to your Codex checkout.\n3. Wire the hooks into `~/.claude/settings.json` per the `PreToolUse` entries in [docs/INSTALL.md](docs/INSTALL.md).\n\nSee [docs/INSTALL.md](docs/INSTALL.md) for the full runbook and [policy/mcp-gate-policy.example.json](policy/mcp-gate-policy.example.json) for the annotated starter policy.\n\n## Adoption Kit\n\nIf you want the shortest receipt-producing path, start with [docs/ADOPTION-KIT.md](docs/ADOPTION-KIT.md). It summarizes the threat model, install path, default-deny examples, local verification commands, demo references, and provider-parity caveats. For the broader trust story across Egress Guard, OPERANT, MCPAudit, and mcpforge, see [docs/CONTROL-PLUS-CALIBRATION.md](docs/CONTROL-PLUS-CALIBRATION.md).\n\n## What it does *not* do\n\nIt is **one layer, not a silver bullet.** It does not track output-side data flow, decode\nencoded payloads, or detect injection carried in tool output, and an in-process hook shares\nthe agent's trust domain. Read [LIMITATIONS.md](LIMITATIONS.md) before relying on it, and\npair it with network-layer controls.\n\n## Security\n\nFound a bypass? Please report it privately; see [SECURITY.md](SECURITY.md). A bypass is a\nvulnerability; don't open a public issue for one.\n\n## Contributing\n\nContributions are welcome; see [CONTRIBUTING.md](CONTRIBUTING.md). The short version: egress\nlogic is additive (never weaken an existing deny), both agents stay in parity off the shared\npolicy, and every behavior change ships with a test.\n\n## License\n\n[Apache-2.0](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaagpatel%2Fcross-provider-egress-guard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaagpatel%2Fcross-provider-egress-guard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaagpatel%2Fcross-provider-egress-guard/lists"}