Skip to content

feat(egress): prepare scoped DNS leases in the Classic backend - #3124

Draft
cwj2001 wants to merge 1 commit into
opensandbox-group:mainfrom
cwj2001:feat/classic-domain-port-engine
Draft

cwj2001 wants to merge 1 commit into
opensandbox-group:mainfrom
cwj2001:feat/classic-domain-port-engine

Conversation

@cwj2001

@cwj2001 cwj2001 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Refs #3123 (M1 of 3). A portless domain allow does not restrict the destination port on the resolved address. This PR prepares the direct Classic dns+nft backend to enforce domain allow rules with TCP ports under defaultAction: deny, including when addresses change or names share an IP. It adds the policy interpretation, nftables enforcement and OSEP-0038.

No public rule shape is enabled in this PR. Sidecar startup, public policy writes, the SDKs and sandbox creation retain their existing behavior. M2 will enable the sidecar API and SDKs together; M3 will enable lifecycle creation.

Testing

  • Not run (explain why)
  • Unit tests — scoped policy parsing and native/mapped address matching; public POST/PATCH still reject the new shape without changing the saved policy or GET response.
  • Integration tests — four nftables tests ran in private Linux network namespaces with no skips. They cover tuple-only DNS grants, same-IP sibling ports, ownership changes and established-flow withdrawal.
  • e2e / manual verification — passed locally on efea0427a2 in rootless Docker (M1 only, not hosted CI). The unmodified Python SDK created a sandbox with existing rules (HTTP 202). On IPv4 and IPv6, only TCP 443 was reachable before DNS resolution; the portless domain grant allowed 80, 443 and 8443, and deleting it left only 443 reachable on the cached addresses. Of 36 fresh TCP connections, 18 echoed and 18 were blocked, confirmed by SYN counters before and after filtering. Domain-plus-port create returned 422 without provisioning; sidecar PATCH and POST returned 400 without changing the policy or traffic verdicts.

Breaking Changes

  • None
  • Yes (describe impact and migration path)

Checklist

  • Linked Issue or clearly described motivation
  • Added/updated docs (if needed) — OSEP-0038
  • Added/updated tests (if needed)
  • Security impact considered — scoped DNS grants must not open the whole address or an unrelated port.
  • Backward compatibility considered — existing public validation and portless rules are unchanged.

Keep DNS-learned TCP grants and reconnect deadlines scoped to the destination address and port. Retain established-only exceptions where withdrawing one owner must not disconnect a still-admitted sibling.

Exercise the manager and packet boundary before exposing the new rule shape through the public API or SDKs. Document the proposed Classic-only scope in OSEP-0038.

Refs opensandbox-group#3123

Signed-off-by: cwj2001 <2965241316@qq.com>
@github-actions github-actions Bot added component/egress documentation Improvements or additions to documentation size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 26, 2026

This branch has not been deployed

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

Labels

component/egress documentation Improvements or additions to documentation size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant