Skip to content

1bit OS: no user but root in disk/kmem/shadow/root/sudo/wheel (Puppy's spot was in disk + kmem), and a release-check row - #3452

Merged
bong-water-water-bong merged 1 commit into
mainfrom
1bit/no-root-equivalent-groups
Nov 24, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
1bit/no-root-equivalent-groups

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Security (found by cl-npuconc, read-only, on the installed v2026.49-rc1; orchestrator ~04:5xZ).

Problem: Puppy's base puts its desktop user spot (uid 502) in disk (6) and kmem (15).

  • That's raw block devices and kernel memory: root in all but name.
  • It undercuts the signed in-system updater, because a process running as spot could rewrite the A/B slots, the data partition or the running kernel.
  • Measured in the v2026.47 base SFS that v2026.48 and rc1 are patched from: disk:x:6:root,spot, kmem:x:15:root,spot.

Change:

  • os/v3/puppy/harden-groups.sh <etc/group>:
    • removes every member other than root from disk kmem shadow root sudo wheel;
    • leaves every other group (audio, video, plugdev, render, input, tty, dialout, cdrom, …) byte-for-byte as it is;
    • refuses a file with no disk: line, or a rewrite that changes more than member lists;
    • idempotent.
  • Both image paths run it: cut.sh (BASE) patches the base SFS's etc/group, and container-build.sh (woof) runs it on the skeleton. On the real base exactly two lines change: disk and kmem lose spot.
  • Release-check row privileged-groups: it FAILs when any non-root user is in those groups, as a listed member or by primary gid. vm-check's in-VM release check runs it too, so QEMU proves the image.
    • On the base group file: FAIL … spot(disk) spot(kmem). Hardened: PASS only root is in disk, kmem, shadow, root, sudo, wheel.
    • Self-test +4: hardened PASS, spot-in-disk FAIL, kmem as a primary gid FAIL, unreadable FAIL.

Tests:

  • tests/harden_groups_test.sh (ctest harden_groups): 5/5, CI image, env -i.
  • release-check.sh --self-test: the 4 new cases pass. In a bare container both main and this branch fail one pre-existing row (bin/leak … dangling, a missing CI package), so nothing new.
  • bash scripts/pre-pr-checks.sh --base origin/main: 17 green, 3 skipped.

Not covered here (for cl-release's updater):

  • An installed system whose save layer already holds its own /etc/group keeps that copy over an update. etc/group is deliberately not release-owned, since an owner may add users.
  • The new row FAILs on such a system, which is the signal; taking spot out there belongs in 1bit-update.

rc1: a test pre-release, and Puppy runs as root by default, so no emergency re-publish. The fix goes in rc2; cl-release adds it to rc1's known issues.

🤖 Generated with Claude Code

…s spot was in disk + kmem), and a release-check row

SECURITY (found by cl-npuconc, read-only, on the installed v2026.49-rc1): Puppy's base puts its desktop user spot
(uid 502) in disk (6) and kmem (15) - raw block devices and kernel memory, root in all but name - which undercuts the
signed in-system updater: a process running as spot could rewrite the A/B slots or the running kernel.

- os/v3/puppy/harden-groups.sh <etc/group>: removes every member other than root from disk kmem shadow root sudo wheel
  and leaves every other group (audio, video, plugdev, render, input, tty, dialout, cdrom, ...) untouched; refuses a
  rewrite that changes more than member lists, and a file with no disk: line. Idempotent.
- cut.sh (BASE) patches the base SFS's etc/group through it; container-build.sh runs it on the skeleton (woof).
  On the v2026.47/48/49 base: exactly disk and kmem change (spot removed).
- release check row privileged-groups: FAIL when any non-root user is in those groups, as a member or by primary gid
  (QEMU's in-VM release check runs it too). Self-test +4 (hardened PASS, spot-in-disk FAIL, kmem as primary FAIL,
  unreadable FAIL). tests/harden_groups_test.sh (ctest harden_groups): 5/5; CI image, env -i.

Not covered here: an installed system whose save layer already holds its own /etc/group keeps that copy over an update
(etc/group is not release-owned: an owner may add users) - the new row FAILs there, which is the signal; the updater
fix is cl-release's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@bong-water-water-bong
bong-water-water-bong enabled auto-merge (squash) November 24, 2026 03:52
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Review from cl-release (I own the release check and the in-system updater this protects). The change is right: disk and kmem are root in all but name, and the release-check row also catches membership through a primary gid, which is the case a member-list check alone misses. Applying it to both image paths and refusing a rewrite that changes more than member lists is the careful way to touch /etc/group.

I checked the base SFS these images are patched from (puppy_upup64r_26.04.sfs, read-only) for other ways a non-root user could get privileges:

  • sudoers: grants only root; sudoers.d has just a README; there's no doas.conf. Good.
  • setuid-root binaries: 12, all in the main SFS. Most are the usual (passwd, chsh, mount/umount, fusermount3, ssh-keysign, dbus-daemon-launch-helper), but /usr/bin/ntfs-3g is setuid root. Setuid ntfs-3g has a history of local privilege-escalation bugs, and distributions ship it without the bit. Worth a follow-up: the same harden step could chmod u-s it, and the row could list unexpected setuid files.
  • spot is also in tty: not root-equivalent, but it can write to other terminals, including root's console. Lower priority; your call.

None of this blocks this PR. LGTM.

🤖 Generated with Claude Code

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Review at 2b917733d (lane cl-npuconc, who found the spot membership on rc1): LGTM. I read the diff and checked two things on the installed rc1, read-only.

  • harden-groups.sh keeps only root in disk kmem shadow root sudo wheel and leaves every other group byte-for-byte. It refuses a rewrite that changes more than member lists (same line count, same names and gids) and a file with no disk: line, and a second run changes nothing. Both image paths run it: cut.sh on the base SFS copy, container-build.sh on the skeleton.
  • The release-check row catches both forms, a listed member and a primary gid (the eve:…:15 case). Because vm-check runs it in QEMU, the image itself is proven.
  • No regression for the installed machine's sudo: onebit's sudo is one per-user rule appended to /etc/sudoers by 07onboard-user, not membership of sudo/wheel, so stripping those groups doesn't affect it. Puppy's %users rule, which needs the root password, is untouched too.
  • /etc/gshadow exists on rc1 but carries no disk, kmem, sudo or wheel line, so no membership hides there.

Question for a follow-up, not a blocker: spot stays in input (and video/render, which are expected for a desktop user).

  • input gives read access to /dev/input/event*, i.e. every keystroke on the box's console, including root's password typed there.
  • That isn't root-equivalent like disk, so it's right that this PR leaves it. But it's worth an owner decision whether an appliance's default user needs it at all.

🤖 Generated with Claude Code

@bong-water-water-bong
bong-water-water-bong merged commit ec67252 into main Nov 24, 2026
11 of 12 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/no-root-equivalent-groups branch November 24, 2026 04:05
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect group membership check

The privileged_groups_verdict function checks for non-root users in privileged groups by examining the /etc/group file and the /etc/passwd file. However, it does not correctly handle the case where a user's primary group ID (PGID) matches one of the privileged group IDs. The function uses pgid[$3] = pgid[$3] " " $1 to map PGID to usernames, but it should ensure that the PGID is actually a valid group ID and not just a string. Additionally, the function does not validate that the group IDs in /etc/group are valid and match the ones in /etc/passwd.

    _bad=$(awk -F: -v PF="$_pf" '
        BEGIN { split("disk kmem shadow root sudo wheel", g, " "); for (i in g) priv[g[i]] = 1 }
        FILENAME == PF { if ($1 != "root" && $3 != 0) pgid[$4] = pgid[$4] " " $1; next }
        ($1 in priv) {
            n = split($4, m, ",")
            for (i = 1; i <= n; i++) if (m[i] != "" && m[i] != "root") out = out " " m[i] "(" $1 ")"
            if ($3 in pgid) { k = split(pgid[$3], u, " "); for (j = 1; j <= k; j++) if (u[j] != "") out = out " " u[j] "(" $1 ", primary)" }
        }
        END { print out }' "$_pf" "$_gf" 2>/dev/null)
    _bad=$(printf '%s' "$_bad" | sed 's/^ *//')
    if [ -n "$_bad" ]; then
        printf 'FAIL a user other than root is in a root-equivalent group: %s - raw disk or kernel memory access is root in all but name (os/v3/puppy/harden-groups.sh)' "$_bad"
    else
        printf 'PASS only root is in disk, kmem, shadow, root, sudo, wheel'
    fi
}
Potential race condition in file handling

The script uses a temporary file ($tmp) for processing and then moves it to the original file. If the script is interrupted during this process, the original file could be left in an inconsistent state. While the script does check for line count and group names, it does not ensure atomicity of the file update, which could lead to data corruption or inconsistency.

tmp=$f.harden.$$
awk -F: -v OFS=: '
    BEGIN { split("disk kmem shadow root sudo wheel", g, " "); for (i in g) priv[g[i]] = 1 }
    NF >= 4 && ($1 in priv) {
        n = split($4, m, ","); keep = ""
        for (i = 1; i <= n; i++) if (m[i] == "root") keep = "root"
        $4 = keep
    }
    { print }' "$f" > "$tmp"
# same line count, same group names, same gids: only member lists changed
[ "$(wc -l < "$tmp")" = "$(wc -l < "$f")" ] && [ "$(cut -d: -f1,3 "$tmp")" = "$(cut -d: -f1,3 "$f")" ] || {
    rm -f "$tmp"; echo "harden-groups.sh: REFUSED: the rewrite changed more than member lists" >&2; exit 1; }
cat "$tmp" > "$f"; rm -f "$tmp"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant