From nobody Tue May 2 18:38:21 2023 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Q9pk54Ycfz49HCt for ; Tue, 2 May 2023 18:38:21 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Q9pk51hvmz3wnc for ; Tue, 2 May 2023 18:38:21 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683052701; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HbDve8sZm3mAE7/cw1mdqxcJuV5dYUOnvuKGde0BX5M=; b=gTl56r9DFVqQzW5Sa2Jy8+gmY3JQkE8MVw7UMSQNbfTva+K2t0oYTvDWEXuq8BcAel9vBa 6MkDFlwoyEmghJBwiG/myiJfs/AMg08NGA6SdytaWOZTMQvX6gCpiN7utn6vlxN4yuNWmM V2Q+6L80i6nOrw/WK9gvMdxi0+EVGKfUAs/baSYAvNfBaxhK0KUY5ERMM3HhY4HO2ahKxB LezVjsoBwWyieeoEMemrpcn8Ff3wIIZPKQakzQ4XlL8LkxorGTJgP+y7Wm09xbCkDl8OjI rBCvVMRQWOwrbzBiwvmxMwcyaqMHajb4j+gO/aOJPc5fR0GRnCTrZ7SutjRD2w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683052701; a=rsa-sha256; cv=none; b=xHs+Abb05QQxZ9CMlCwjIAROFtohGApBBtI3GCAGpgSFxp4hv9SmbqM32ASqksa479DvtY pL8b/Uyy9HyRvz5oEScbcUE8oIIj/JA51CSytqIydfre2xzs0H9UIjbLN1tUSTalCKz+kB rdwQhL8Z8OrYiq5N2aIGoglVAkJGqaBBuzIPLOPklCUP/2BqkVjwD1y5XYBtXh0zwUmOAu Ih2nbI67Qtib8s7gr5DpLXrBNwDpeVFqgu9W9E+CDdiTyoequ0FYPUxSqWEpYb3t2ETPB2 5ZAwpQAPoqW4f7OhX5IK0+PXoxiNYXvfsjkvRXDNX2JLT5o3TbEpjHLImCyaQw== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Q9pk50mfSz102s for ; Tue, 2 May 2023 18:38:21 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 342IcLBZ055815 for ; Tue, 2 May 2023 18:38:21 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 342IcLjp055814 for bugs@FreeBSD.org; Tue, 2 May 2023 18:38:21 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 271211] chroot -g inconsistently drops additional groups Date: Tue, 02 May 2023 18:38:21 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 13.2-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: nospam@mgedv.net X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D271211 Bug ID: 271211 Summary: chroot -g inconsistently drops additional groups Product: Base System Version: 13.2-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Many People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: nospam@mgedv.net finding: /usr/sbin/chroot does NOT drop additional groups, if -G was NOT explicitely specified as an argument and the calling process is in more than 1 OS group (unclear assumption!). current group memberships of the calling process can vary depending on where scripts using it are called (e.g. system boot vs. interactive shell, see 13= .2 example beyond). this can lead to unexpected and even insecure results/behaviour. proof: ------------------------------------------------------------------------ 7.2-RELEASE # id uid=3D0(root) gid=3D0(wheel) groups=3D0(wheel),5(operator) box:/# chroot -u user -g home / /usr/bin/id uid=3D1000(user) gid=3D1000(home) groups=3D1000(home),0(wheel),5(operator) ------------------------------------------------------------------------ 11.1-STABLE (1101501) # id uid=3D0(root) gid=3D0(wheel) groups=3D0(wheel),5(operator) # chroot -u user -g home / /usr/bin/id uid=3D1000(user) gid=3D1000(home) groups=3D1000(home),5(operator) ------------------------------------------------------------------------ 12.2-STABLE (1202504) # id uid=3D0(root) gid=3D0(wheel) groups=3D0(wheel),5(operator) # chroot -u user -g home / /usr/bin/id uid=3D1000(user) gid=3D1000(home) groups=3D1000(home),0(wheel),5(operator) ------------------------------------------------------------------------ 13.2-RELEASE (1302001) # id uid=3D0(root) gid=3D0(wheel) groups=3D0(wheel),5(operator) # chroot -u user -g home / /usr/bin/id uid=3D1000(user) gid=3D1000(home) groups=3D1000(home),0(wheel),5(operator) ------------------------------------------------------------------------ side note: 13.2-RELEASE during bootup looks like this: # id called by RC script: uid=3D0(root) gid=3D0(wheel) groups=3D0(wheel) # same chroot command as above called by script: uid=3D1000(user) gid=3D1000(home) groups=3D1000(home) ------------------------------------------------------------------------ as the base chroot code was introduced 2003, idk if this is really a (sec?) bug/insecure behaviour. https://cgit.freebsd.org/src/commit/usr.sbin/chroot?id=3D4fb3a3060cfe746c6c= 6699bc9b52d29594eb409b if this works like expected, maybe an update to the manpage for clarity on usage would make sense. workaround: i'd call chroot like this, which works as expected and mitigates this behav= iour at least for me: /usr/sbin/chroot -g newgrp -G newgrp -u newusr / /path/to/exec --=20 You are receiving this mail because: You are the assignee for the bug.=