Skip to content

Commit 2d17bfc

Browse files
authored
fix: always allow localhost bind/inbound in macOS Seatbelt profile (#12)
On macOS, the Seatbelt sandbox denied network-bind and network-inbound by default, requiring AllowLocalBinding to be set per-agent. This broke OAuth login flows (e.g. Claude /login) which start a local callback server on a random port. On Linux, the isolated network namespace allows unrestricted local binding. Align macOS behavior by always including localhost bind/inbound rules. Outbound to localhost remains gated on AllowLocalOutbound.
1 parent 23990b3 commit 2d17bfc

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

internal/sandbox/macos.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -578,16 +578,17 @@ func GenerateSandboxProfile(params MacOSSandboxParams) string {
578578
if !params.NeedsNetworkRestriction {
579579
profile.WriteString("(allow network*)\n")
580580
} else {
581-
if params.AllowLocalBinding {
582-
// Allow binding and inbound connections on localhost (for servers)
583-
profile.WriteString(`(allow network-bind (local ip "localhost:*"))
581+
// Always allow localhost binding and inbound connections.
582+
// This matches Linux behavior where the isolated network namespace
583+
// allows unrestricted local binding. Many tools need this for OAuth
584+
// callbacks, MCP servers, dev servers, etc.
585+
profile.WriteString(`(allow network-bind (local ip "localhost:*"))
584586
(allow network-inbound (local ip "localhost:*"))
585587
`)
586-
// Process can make outbound connections to localhost
587-
if params.AllowLocalOutbound {
588-
profile.WriteString(`(allow network-outbound (local ip "localhost:*"))
588+
// Process can make outbound connections to localhost
589+
if params.AllowLocalOutbound {
590+
profile.WriteString(`(allow network-outbound (local ip "localhost:*"))
589591
`)
590-
}
591592
}
592593

593594
if params.AllowAllUnixSockets {

0 commit comments

Comments
 (0)