From 87bbc2c0a451a09ca0ce2bc83dc7242da0acfc09 Mon Sep 17 00:00:00 2001 From: adababys Date: Wed, 11 Nov 2026 14:00:52 +0800 Subject: [PATCH] fix(featureflags): default per-sandbox connection limits to a finite cap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Re: #3681. TCPFirewallMaxConnectionsPerSandbox (egress TCP firewall) and SandboxMaxIncomingConnections (ingress HTTP proxy) both defaulted to -1 (unlimited). connlimit.TryAcquire treats maxLimit < 0 as always-admit, so the per-sandbox connection limiters that already exist in the orchestrator are INERT in any deployment that does not set these flags — including, by default, a self-hosted / OSS deployment with no LaunchDarkly override. That is exactly the unbounded shared-host-resource boundary #3681 asks about: a sandbox can hold unlimited host connections/goroutines/fds with no per-sandbox accounting. Default both to a generous finite cap (1024) so the limiters are active out of the box. The limiters, metrics, and refusal paths already exist; this only flips the default so they engage. Blast radius: e2b's own deployments set these via LaunchDarkly, which overrides the code default, so prod behavior is unchanged except where LD returns null. Deployments with no override go from unbounded to a 1024 ceiling — strictly safer. Operators raise or disable (-1) per team via the flag. Note on the value: 1024 is a conservative starting point, well above any normal per-sandbox connection count (the #3681 PoC used 32) and in line with existing finite caps in this file (MaxSandboxesPerNode=200, RemoteClusterInstancesPerConnection=64, freeze-guest-hierarchy-max-cgroups=512). The exact number is a deployment policy call — happy to adjust to whatever the maintainers prefer; the flag makes it a one-line change and a runtime override. --- packages/shared/pkg/featureflags/flags.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/shared/pkg/featureflags/flags.go b/packages/shared/pkg/featureflags/flags.go index 5cac0e21ad..0531ae6384 100644 --- a/packages/shared/pkg/featureflags/flags.go +++ b/packages/shared/pkg/featureflags/flags.go @@ -880,12 +880,16 @@ var ( PauseResumePrefetchHarvestTimeoutMsFlag = NewIntFlag("pause-resume-prefetch-harvest-timeout-ms", 15000) // 15s // TCPFirewallMaxConnectionsPerSandbox is the maximum number of concurrent TCP firewall - // connections allowed per sandbox. Negative means no limit. - TCPFirewallMaxConnectionsPerSandbox = NewIntFlag("tcpfirewall-max-connections-per-sandbox", -1) + // connections allowed per sandbox. Negative means no limit. The default is a + // generous finite cap so a deployment with no LaunchDarkly override still bounds + // per-sandbox egress connections (see #3681); operators raise or disable it per team. + TCPFirewallMaxConnectionsPerSandbox = NewIntFlag("tcpfirewall-max-connections-per-sandbox", 1024) // SandboxMaxIncomingConnections is the maximum number of concurrent HTTP proxy - // connections allowed per sandbox. Negative means no limit. - SandboxMaxIncomingConnections = NewIntFlag("sandbox-max-incoming-connections", -1) + // connections allowed per sandbox. Negative means no limit. The default is a + // generous finite cap so a deployment with no LaunchDarkly override still bounds + // per-sandbox ingress connections (see #3681); operators raise or disable it per team. + SandboxMaxIncomingConnections = NewIntFlag("sandbox-max-incoming-connections", 1024) // BuildBaseRootfsSizeLimitMB is the maximum size of the base rootfs filesystem created from the OCI image, in MB. BuildBaseRootfsSizeLimitMB = NewIntFlag("build-base-rootfs-size-limit-mb", 25000)