package: deb postinst probes userns as root — chrome-sandbox lands 0755 and the installed app SIGTRAPs on Ubuntu 24.04 #490

Closed
opened 2026-08-12 19:08:00 +00:00 by ben · 1 comment
Owner

Symptom (live, #471's install proof, 2026-08-12)

apt install of ourcloud_0.1.0_amd64.deb on the reference target (Ubuntu 24.04, kernel.apparmor_restrict_unprivileged_userns=1) succeeds, but launching the installed app crashes at once (SIGTRAP core dump):

FATAL:setuid_sandbox_host.cc(163)] The SUID sandbox helper binary was found, but is
not configured correctly. Rather than run without sandboxing I'm aborting now. You
need to make sure that /opt/OurCloud/chrome-sandbox is owned by root and has mode 4755.

ls -l /opt/OurCloud/chrome-sandbox after install: -rwxr-xr-x root root — 0755, no SUID bit.

Cause

electron-builder's stock deb postinst decides SUID-vs-not with:

if ! { [[ -L /proc/self/ns/user ]] && unshare --user true; }; then
    chmod 4755 '/opt/OurCloud/chrome-sandbox' || true
else
    chmod 0755 '/opt/OurCloud/chrome-sandbox' || true
fi

That runs as root (apt maintainer script). Root is exempt from Ubuntu 24.04's AppArmor userns restriction (apparmor_restrict_unprivileged_userns=1 — the restriction 24.04 actually uses; the legacy kernel.unprivileged_userns_clone sysctl reads 1), so unshare --user true succeeds in a context that proves nothing about the unprivileged user who launches the app. The 0755 branch is taken; the user's Chromium can neither create a userns (AppArmor) nor exec a SUID helper (no bit) → FATAL abort.

ADR 0168's premise — "electron-builder's stock deb postinst root-SUIDs chrome-sandbox" — is false on the reference target. #463's sandbox layout proof asserted the postinst carries a SUID story, not that the branch taken on Ubuntu 24.04 is the right one — the exact class of defect only #471's real install could surface.

Fix

Ship our own deb afterInstall script (electron-builder: deb.fpm/afterInstall in electron-builder.yml) that sets chown root:root && chmod 4755 on chrome-sandbox unconditionally — Google Chrome's own deb ships 4755 unconditionally; a SUID helper on a userns-capable system is harmless (Chromium prefers userns and ignores the helper), while the conditional is what crashes. Keep the rest of the stock template (update-alternatives, desktop DB refresh).

  • Amend ADR 0168's sandbox-story paragraph to record the stock-postinst trap and the unconditional-SUID ruling.
  • Extend scripts/package-layout-check.sh: assert the built deb's postinst contains the unconditional 4755 (and no unshare --user conditional) — sandbox-provable, keeps the regression pinned.
  • Append the GOTCHAS entry (ADR 0160) in the fix commit: stock electron-builder deb postinst probes userns as root → 0755 chrome-sandbox → instant SIGTRAP on Ubuntu 24.04.
  • Manual workaround until then (posted on #471): sudo chmod 4755 /opt/OurCloud/chrome-sandbox.

Acceptance

  • scripts/package-app.sh → fresh .deb whose postinst SUIDs chrome-sandbox unconditionally; package-layout-check.sh asserts it.
  • ADR 0168 amended + GOTCHAS entry appended in the same commit.
  • #471's zero-manual-steps criterion is achievable: a fresh install on Ubuntu 24.04 launches with no chmod (re-proof rides #471, which stays the live gate).
## Symptom (live, #471's install proof, 2026-08-12) `apt install` of `ourcloud_0.1.0_amd64.deb` on the reference target (Ubuntu 24.04, `kernel.apparmor_restrict_unprivileged_userns=1`) succeeds, but launching the installed app crashes at once (SIGTRAP core dump): ``` FATAL:setuid_sandbox_host.cc(163)] The SUID sandbox helper binary was found, but is not configured correctly. Rather than run without sandboxing I'm aborting now. You need to make sure that /opt/OurCloud/chrome-sandbox is owned by root and has mode 4755. ``` `ls -l /opt/OurCloud/chrome-sandbox` after install: `-rwxr-xr-x root root` — **0755, no SUID bit**. ## Cause electron-builder's stock deb postinst decides SUID-vs-not with: ```bash if ! { [[ -L /proc/self/ns/user ]] && unshare --user true; }; then chmod 4755 '/opt/OurCloud/chrome-sandbox' || true else chmod 0755 '/opt/OurCloud/chrome-sandbox' || true fi ``` That runs **as root** (apt maintainer script). Root is exempt from Ubuntu 24.04's AppArmor userns restriction (`apparmor_restrict_unprivileged_userns=1` — the restriction 24.04 actually uses; the legacy `kernel.unprivileged_userns_clone` sysctl reads `1`), so `unshare --user true` succeeds in a context that proves nothing about the unprivileged user who launches the app. The 0755 branch is taken; the user's Chromium can neither create a userns (AppArmor) nor exec a SUID helper (no bit) → FATAL abort. **ADR 0168's premise — "electron-builder's stock deb postinst root-SUIDs `chrome-sandbox`" — is false on the reference target.** #463's sandbox layout proof asserted the postinst *carries* a SUID story, not that the branch taken on Ubuntu 24.04 is the right one — the exact class of defect only #471's real install could surface. ## Fix Ship our own deb `afterInstall` script (electron-builder: `deb.fpm`/`afterInstall` in `electron-builder.yml`) that sets `chown root:root && chmod 4755` on `chrome-sandbox` **unconditionally** — Google Chrome's own deb ships 4755 unconditionally; a SUID helper on a userns-capable system is harmless (Chromium prefers userns and ignores the helper), while the conditional is what crashes. Keep the rest of the stock template (update-alternatives, desktop DB refresh). - Amend ADR 0168's sandbox-story paragraph to record the stock-postinst trap and the unconditional-SUID ruling. - Extend `scripts/package-layout-check.sh`: assert the built deb's postinst contains the **unconditional** 4755 (and no `unshare --user` conditional) — sandbox-provable, keeps the regression pinned. - Append the GOTCHAS entry (ADR 0160) in the fix commit: *stock electron-builder deb postinst probes userns as root → 0755 chrome-sandbox → instant SIGTRAP on Ubuntu 24.04*. - Manual workaround until then (posted on #471): `sudo chmod 4755 /opt/OurCloud/chrome-sandbox`. ## Acceptance - [ ] `scripts/package-app.sh` → fresh `.deb` whose postinst SUIDs `chrome-sandbox` unconditionally; `package-layout-check.sh` asserts it. - [ ] ADR 0168 amended + GOTCHAS entry appended in the same commit. - [ ] #471's zero-manual-steps criterion is achievable: a fresh install on Ubuntu 24.04 launches with no chmod (re-proof rides #471, which stays the live gate).
Author
Owner

close-report for #490 — status success

✅ close-report gates passed — every claim verified against main; closing.

envelope
{
  "issue": 490,
  "status": "success",
  "commits": [
    "000eb34"
  ],
  "changed_files": [
    "STATUS.md",
    "app/PACKAGING.md",
    "app/build/deb/after-install.sh",
    "app/electron-builder.yml",
    "docs/GOTCHAS.md",
    "docs/adr/0168-operator-app-packages-as-a-deb-via-electron-builder.md",
    "scripts/package-layout-check.sh"
  ],
  "tests": [
    {
      "command": "bash -n scripts/package-layout-check.sh",
      "exit_code": 0
    },
    {
      "command": "bash -n app/build/deb/after-install.sh",
      "exit_code": 0
    },
    {
      "command": "dpkg-deb build + extract of the macro-expanded postinst, then the gate-6 predicates: grep 4755 (pass), !grep 'unshare --user' && !grep 'chmod 0755' (pass); stock template correctly fails the new gate",
      "exit_code": 0
    }
  ],
  "criteria": {
    "scripts/package-app.sh -> fresh .deb whose postinst SUIDs chrome-sandbox unconditionally; package-layout-check.sh asserts it": "app/electron-builder.yml gains deb.afterInstall: build/deb/after-install.sh; app/build/deb/after-install.sh chown root:root && chmod 4755 chrome-sandbox unconditionally (no unshare --user probe), keeping the stock update-alternatives + mime/desktop DB refresh. scripts/package-layout-check.sh gate 6 extended to assert the unconditional 4755 AND absence of the userns probe. The in-container deb build is out of scope (glibc wall #377) as in #463; the assertion is the container-provable half and is proven end-to-end against a real dpkg-deb-built postinst.",
    "ADR 0168 amended + GOTCHAS entry appended in the same commit": "docs/adr/0168-*.md decision #2 sandbox-story amended (stock-postinst trap + unconditional-SUID ruling) and layout-proof bullet updated; docs/GOTCHAS.md entry 21 appended — both in commit 000eb34.",
    "#471's zero-manual-steps criterion is achievable: a fresh install on Ubuntu 24.04 launches with no chmod (re-proof rides #471)": "The shipped postinst now root-SUIDs chrome-sandbox 4755 unconditionally, so a fresh install needs no manual chmod; #471 stays the live re-proof gate. Container cannot execute the packaged Electron (#377), so the runtime re-proof rides #471 as the ticket specifies."
  },
  "summary": "Ship our own deb afterInstall that root-SUIDs chrome-sandbox unconditionally (fixing the Ubuntu 24.04 SIGTRAP), with the layout check asserting it, ADR 0168 amended and GOTCHAS 21 appended.",
  "blockers": []
}
**close-report** for #490 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; closing. <details><summary>envelope</summary> ```json { "issue": 490, "status": "success", "commits": [ "000eb34" ], "changed_files": [ "STATUS.md", "app/PACKAGING.md", "app/build/deb/after-install.sh", "app/electron-builder.yml", "docs/GOTCHAS.md", "docs/adr/0168-operator-app-packages-as-a-deb-via-electron-builder.md", "scripts/package-layout-check.sh" ], "tests": [ { "command": "bash -n scripts/package-layout-check.sh", "exit_code": 0 }, { "command": "bash -n app/build/deb/after-install.sh", "exit_code": 0 }, { "command": "dpkg-deb build + extract of the macro-expanded postinst, then the gate-6 predicates: grep 4755 (pass), !grep 'unshare --user' && !grep 'chmod 0755' (pass); stock template correctly fails the new gate", "exit_code": 0 } ], "criteria": { "scripts/package-app.sh -> fresh .deb whose postinst SUIDs chrome-sandbox unconditionally; package-layout-check.sh asserts it": "app/electron-builder.yml gains deb.afterInstall: build/deb/after-install.sh; app/build/deb/after-install.sh chown root:root && chmod 4755 chrome-sandbox unconditionally (no unshare --user probe), keeping the stock update-alternatives + mime/desktop DB refresh. scripts/package-layout-check.sh gate 6 extended to assert the unconditional 4755 AND absence of the userns probe. The in-container deb build is out of scope (glibc wall #377) as in #463; the assertion is the container-provable half and is proven end-to-end against a real dpkg-deb-built postinst.", "ADR 0168 amended + GOTCHAS entry appended in the same commit": "docs/adr/0168-*.md decision #2 sandbox-story amended (stock-postinst trap + unconditional-SUID ruling) and layout-proof bullet updated; docs/GOTCHAS.md entry 21 appended — both in commit 000eb34.", "#471's zero-manual-steps criterion is achievable: a fresh install on Ubuntu 24.04 launches with no chmod (re-proof rides #471)": "The shipped postinst now root-SUIDs chrome-sandbox 4755 unconditionally, so a fresh install needs no manual chmod; #471 stays the live re-proof gate. Container cannot execute the packaged Electron (#377), so the runtime re-proof rides #471 as the ticket specifies." }, "summary": "Ship our own deb afterInstall that root-SUIDs chrome-sandbox unconditionally (fixing the Ubuntu 24.04 SIGTRAP), with the layout check asserting it, ADR 0168 amended and GOTCHAS 21 appended.", "blockers": [] } ``` </details>
ben closed this issue 2026-08-12 19:26:21 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#490
No description provided.