mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[PR #207] [MERGED] feat(network): support domain-based egress control #252
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#252
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/kvcache-ai/AgentENV/pull/207
Author: @LSX-s-Software
Created: 8/22/2026
Status: ✅ Merged
Merged: 8/24/2026
Merged by: @yingdi-shan
Base:
main← Head:feat/domain-based-egress-control📝 Commits (5)
b816db7feat(network): support domain-based egress control9b4fbb9refactor(network): store egress CIDRs as IP networks8e6790frefactor(network): use bounded host DNS resolverd6d7946refactor(network): use mutable slot lifecycle access to remove concurrency control1de7324fix(network): reject malformed host headers📊 Changes
16 files changed (+2249 additions, -105 deletions)
View changed files
📝
Cargo.lock(+42 -0)📝
Cargo.toml(+4 -1)📝
docs/src/SUMMARY.md(+1 -0)📝
docs/src/concepts/sandboxes.md(+5 -1)📝
docs/src/internals/architecture.md(+1 -10)➕
docs/src/internals/networking.md(+194 -0)📝
src/api/impls/sandbox.rs(+131 -17)📝
src/sandbox/firecracker/sandbox.rs(+3 -3)📝
src/sandbox/mod.rs(+4 -1)➕
src/sandbox/network/egress_proxy.rs(+1103 -0)📝
src/sandbox/network/manager.rs(+32 -17)📝
src/sandbox/network/mod.rs(+6 -1)📝
src/sandbox/network/policy.rs(+301 -27)➕
src/sandbox/network/resolver.rs(+274 -0)📝
src/sandbox/network/slot.rs(+80 -27)📝
tests/integration/fc.rs(+68 -0)📄 Description
What
Add E2B-compatible domain-based egress control for sandbox network policies. Domain entries in
allowOutare now enforced for new HTTP/HTTPS connections through a namespace-local transparent proxy, with trusted host-side DNS resolution and lifecycle cleanup.Why
CIDR-only rules cannot express the common requirement of allowing a sandbox to reach a named service while denying all other internet destinations. This change makes domain allowlists usable while preserving existing CIDR behavior, policy replacement semantics, and warm-pool reuse.
Related issue
No linked issue; this PR follows the existing E2B-compatible network-policy contract.
Scope and non-goals
Included:
*.example.com, and*patterns.denyOut: ["0.0.0.0/0"].Excluded:
Design and behavior changes
NetworkManagerowns a process-wideEgressProxyregistry. Each namespace that needs proxy mediation gets its own listener on the fixed namespace-local port15000; the listener is not exposed as a host port. Namespace NAT redirects only TCP/80 and TCP/443. The proxy recovers the original destination, parses HTTP Host or TLS SNI, resolves candidates in a long-lived host-netns resolver, applies absolute-deny and domain policy checks, then relays the connection without terminating TLS.Policy updates stage the new proxy policy and commit filter/NAT rules as one namespace update. Existing connections retain the policy selected when accepted; tracked sockets are closed during proxy/slot teardown so namespace resources can be safely released and reused.
Compatibility and operations
allowOut/denyOutfields are extended to accept domain patterns; no generated protocol changes.15000is bound only inside each sandbox namespace.Validation
make fmt(already run by the author)make clippy(already run by the author)make test-unit(already run by the author)make -C services test(not applicable;services/is unchanged)maketarget (not applicable; generated API code is unchanged)Commands and results:
Skipped checks and reasons:
Risks and reviewer notes
src/sandbox/network/policy.rsandsrc/sandbox/network/egress_proxy.rs; domain interception is intentionally limited to TCP/80 and TCP/443.Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.