Skip to content

feat: add egress/ingress Off switches for traffic blocking#2166

Open
levb wants to merge 8 commits intolev-ingress-controlfrom
lev-net-on-off
Open

feat: add egress/ingress Off switches for traffic blocking#2166
levb wants to merge 8 commits intolev-ingress-controlfrom
lev-net-on-off

Conversation

@levb
Copy link
Contributor

@levb levb commented Mar 18, 2026

Summary

  • Adds egressOff and ingressOff boolean fields to the sandbox network config (OpenAPI, proto, DB types)
  • When set, all traffic is denied immediately without iterating allow/deny rules
  • Off is mutually exclusive with allow/deny rules — the API rejects requests that set both
  • The legacy allowInternetAccess=false now sets egressOff=true internally instead of injecting 0.0.0.0/0 into the deny list
  • Egress Off is enforced at three layers: nftables (non-TCP), TCP firewall proxy (TCP with hostname), and pre-parsed ACL checks
  • Ingress Off is enforced at the reverse proxy layer, blocking all non-envd inbound traffic
  • Both switches work for create and dynamic update (PUT /sandboxes/{id}/network)
levb and others added 2 commits March 18, 2026 14:32
Add `off` bool to egress/ingress proto configs, OpenAPI spec, and DB types. When set, all traffic is denied immediately without iterating rules. Replaces the legacy `allow_internet_access=false` pattern of injecting 0.0.0.0/0 into denied list. Off is mutually exclusive with allow/deny rules (validated at API layer). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Rename validateEgressRules → validateEgress, validateIngressRules → validateIngress. Each now takes an `off` bool and handles the mutual exclusivity check internally, removing duplicated logic from both the create and update handlers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@levb levb changed the title Lev net on off feat: add egress/ingress Off switches for traffic blocking Mar 18, 2026
github-actions bot and others added 3 commits March 18, 2026 21:48
Move DerefOrDefault calls inside the validate functions so callers pass raw API pointer fields directly without pre-dereferencing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
levb and others added 3 commits March 18, 2026 14:58
Move the acl.Off check before the domain loop in isEgressAllowed. Previously, if Off=true coexisted with AllowedDomains (possible via direct gRPC), a matching domain would bypass the Off restriction. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add off to egress/ingress event data for observability. Remove ACL.IsOff() — all callers use acl.Off directly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Off blocks unconditionally — including allow rules. The legacy allowInternetAccess=false path needs allow rules to take precedence over the deny, so revert to the 0.0.0.0/0 deny pattern for that code path. Off is only for the new explicit egressOff API field. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@levb levb marked this pull request as ready for review March 18, 2026 22:49
@chatgpt-codex-connector
Copy link

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@levb levb assigned dobrac and unassigned matthewlouisbrockman Mar 18, 2026
Copy link
Contributor

@dobrac dobrac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets not do the Off right now and implement only the "AllowInternetAccess" switch for the egress network setup in the update_network API call.

@ValentaTomas ValentaTomas removed their request for review March 21, 2026 06:41
@levb
Copy link
Contributor Author

levb commented Mar 22, 2026

@dobrac I am not sure I see the value of adding this shortcut: it would accomplish nothing different from setting egress to Deny All, which can already be accomplished with the Update API. AllowInternetAccess is not used for anything else. I recommend we do not do it and close the PR. WDYT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants