Skip to content

Commit 0283fdc

Browse files
blink-so[bot]f0ssel
andcommitted
fix: preserve jail group when dropping privileges on macOS
Previously, we were changing both UID and GID to the original user, which broke network jailing because the subprocess was no longer in the jail group that gets redirected through the proxy. Now we: - Change UID to original user (for correct user identity) - Keep GID as jail group (for network isolation) This maintains both user identity and network jailing functionality. Co-authored-by: f0ssel <[email protected]>
1 parent 42dd8bf commit 0283fdc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

network/macos.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,14 @@ func (m *MacOSNetJail) Execute(command []string, extraEnv map[string]string) err
114114
if err != nil {
115115
m.logger.Warn("Invalid SUDO_GID, subprocess will run as root", "sudo_gid", sudoGID, "error", err)
116116
} else {
117+
// Use original user ID but KEEP the jail group for network isolation
117118
cmd.SysProcAttr = &syscall.SysProcAttr{
118119
Credential: &syscall.Credential{
119120
Uid: uint32(uid),
120-
Gid: uint32(gid),
121+
Gid: uint32(m.groupID), // Keep jail group, not original user's group
121122
},
122123
}
123-
m.logger.Debug("Dropping privileges to original user", "uid", uid, "gid", gid)
124+
m.logger.Debug("Dropping privileges to original user with jail group", "uid", uid, "jail_gid", m.groupID)
124125
}
125126
}
126127
}

0 commit comments

Comments
 (0)