From 2deca866e2f44a8abb71409c766c1b3b06ff7956 Mon Sep 17 00:00:00 2001 From: SaladDay <1203511142@qq.com> Date: Tue, 27 Oct 2026 20:18:59 +0000 Subject: [PATCH] Disable strict hostname enforcement only on microsandbox create --- services/core/tools/microsandbox-provider/README.md | 2 +- services/core/tools/microsandbox-provider/bootstrap.go | 4 ++++ services/core/tools/microsandbox-provider/network.go | 6 +----- services/core/tools/microsandbox-provider/network_test.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/services/core/tools/microsandbox-provider/README.md b/services/core/tools/microsandbox-provider/README.md index ebeee909d..20004d89c 100644 --- a/services/core/tools/microsandbox-provider/README.md +++ b/services/core/tools/microsandbox-provider/README.md @@ -20,7 +20,7 @@ The checkpoint root is a separate adapter-owned directory, mode 0700, with a pri ## Create and bootstrap -Create names the VM from a hash of the installation and allocation reference plus the compute generation; a name never serves another incarnation. It creates the VM with the saved CPUs and memory as both initial and maximum, a managed root disk of `root_disk_mib`, the explicitly resolved workspace directory mounted at `/environment`, user 1000:1000, working directory `/` and the node's network policy ([`bootstrap.go`](bootstrap.go)). The resource checks run before bootstrap. Creation and restore retain the SDK's strict hostname policy enforcement; the adapter does not disable it. +Create names the VM from a hash of the installation and allocation reference plus the compute generation; a name never serves another incarnation. It creates the VM with the saved CPUs and memory as both initial and maximum, a managed root disk of `root_disk_mib`, the explicitly resolved workspace directory mounted at `/environment`, user 1000:1000, working directory `/` and the node's network policy ([`bootstrap.go`](bootstrap.go)). The resource checks run before bootstrap. Creation disables the SDK's strict hostname policy enforcement, so domain allows match by the guest's DNS answer and the TLS server name without TLS interception; restore accepts only the policy rules and cannot set it. Workspace, staging and outputs share the `/environment` filesystem, which keeps the Runtime's cross-device and link checks intact; the layered root filesystem can report different device IDs for a directory and its upper-layer files, so it holds no workspace data. The filesystem provider owns the directory; sandbox removal never deletes it. The binding and resource rules belong to [Workspace filesystem protocol](../../../../docs/workspace-provider.md#attachment). The [Runtime bootstrap](../../../../docs/runtime-bootstrap.md) owns the Runtime directory layout. diff --git a/services/core/tools/microsandbox-provider/bootstrap.go b/services/core/tools/microsandbox-provider/bootstrap.go index f3645a1d6..a5f9e27aa 100644 --- a/services/core/tools/microsandbox-provider/bootstrap.go +++ b/services/core/tools/microsandbox-provider/bootstrap.go @@ -56,6 +56,10 @@ func (b backend) create(ctx context.Context) (wire.Response, error) { if e != nil { return wire.Response{}, e } + // Strict hostname enforcement accepts a domain allow over TLS only with TLS + // interception, so the domain allows of a not-public egress would never pass + // HTTPS. Restore cannot set it (the SDK takes only the policy there). + network.DisableStrict = true live, e := sdk.CreateSandbox(ctx, c.Name, // Every compatible node holds the pinned image; nothing is ever pulled. sdk.WithImage(b.q.Config.Image), sdk.WithPullPolicy(sdk.PullPolicyNever), sdk.WithMemory(b.q.Config.MemoryMiB), sdk.WithCPUs(b.q.Config.CPUs), diff --git a/services/core/tools/microsandbox-provider/network.go b/services/core/tools/microsandbox-provider/network.go index 3b8b5a4f2..5c8c05e63 100644 --- a/services/core/tools/microsandbox-provider/network.go +++ b/services/core/tools/microsandbox-provider/network.go @@ -46,10 +46,6 @@ const resolveTimeout = 5 * time.Second // and rebind protection already refuse private ones // 7. public addresses, when Public // -// Strict hostname enforcement is off: it accepts a domain allow over TLS only -// with TLS interception, so the domain allows of rule 6 would never pass HTTPS. -// They match by the guest's DNS answer and the TLS server name instead. -// // Core and PrivateDomains names are resolved together under one deadline. A // PrivateDomains name that does not resolve gets no address rule and is // reported to report. @@ -99,7 +95,7 @@ func egressNetwork(ctx context.Context, coreURL string, egress sandbox.Egress, r slices.Sort(private) private = slices.Compact(private) - n := &sdk.NetworkConfig{DefaultEgress: sdk.PolicyActionDeny, DefaultIngress: sdk.PolicyActionDeny, DisableStrict: true} + n := &sdk.NetworkConfig{DefaultEgress: sdk.PolicyActionDeny, DefaultIngress: sdk.PolicyActionDeny} allow := func(destination, protocol, port string) { n.Rules = append(n.Rules, sdk.PolicyRule{Action: sdk.PolicyActionAllow, Direction: sdk.PolicyDirectionEgress, Destination: destination, Protocol: sdk.PolicyProtocol(protocol), Port: port}) } diff --git a/services/core/tools/microsandbox-provider/network_test.go b/services/core/tools/microsandbox-provider/network_test.go index e4fa496bc..cb7f4dcbf 100644 --- a/services/core/tools/microsandbox-provider/network_test.go +++ b/services/core/tools/microsandbox-provider/network_test.go @@ -33,7 +33,7 @@ func rules(t *testing.T, egress sandbox.Egress, dns map[string][]string) (string if err != nil { t.Fatal(err) } - if n.DefaultEgress != "deny" || n.DefaultIngress != "deny" || !n.DisableStrict || n.DNS != nil { + if n.DefaultEgress != "deny" || n.DefaultIngress != "deny" || n.DisableStrict || n.DNS != nil { t.Fatalf("defaults or DNS options changed: %+v", n) } var lines []string