You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[bug] SMB1 server default config leaves connection count and unauthenticated connection lifetime unbounded #1527
With a default server.Config, the SMB1 server accepts an unlimited number of connections and keeps every one open indefinitely, including connections that never authenticate.
Line(s) / function(s):Config.Timeout at L83–L85 and Config.MaxConnections at L105–L108; NewServer() at L270–L333; (*Server).Serve() at L425–L427; (*Server).ServeConn() at L472–L474; (*Connection).serve() at L201–L231
Category
resource-leak
Severity
medium
A remote, unauthenticated peer can hold an unbounded number of connections, and their goroutines and buffers, on a server running the default configuration.
Reproduction / Evidence
Reproducible at runtime. Start a server with NewServer(Config{}), serve it on a loopback listener, open a raw TCP connection and send nothing:
--- FAIL: TestProbeSilentConnectionOnDefaultConfig (3.00s)
zz_probe_test.go:27: silent connection to a default-config server still open after 3s (read tcp 127.0.0.1:42434->127.0.0.1:35567: i/o timeout); MaxConnections=0 Timeout=0s
The connection stays open until the peer closes it. In the code:
MaxConnections is documented as "Zero means unbounded" (L107) and NewServer() leaves it at zero, so slots is nil and acquireSlot() always succeeds.
Timeout is documented as "Zero means no bound" (L84). Serve() (L425) and ServeConn() (L472) only call SetTimeout when it is positive, so serve() blocks in Transport.Receive() (connection.go L217) with no read deadline.
The SMB2 server had the same defect, fixed by #1507 / PR #1508.
Expected Behavior
The default configuration bounds the number of concurrent connections, and drops connections that do not authenticate, or sit idle holding nothing, within a bounded time. Explicit settings can still lift these bounds.
Actual Behavior
Both the number of connections and the time an unauthenticated or idle connection is kept are unbounded unless the embedder sets MaxConnections and Timeout.
Root Cause
Config has no default for MaxConnections, and its only time bound, Timeout, applies to every read. That makes it unsuitable as a default, because it would also drop authenticated clients that are legitimately quiet, so it was left unset.
Activity
Merge pull request #1528 from TheManticoreProject/bugfix-smb1-server-…