Repository navigation
Harden CUPS printer discovery - #8627
Conversation
There was a problem hiding this comment.
Pull request overview
Hardens CUPS printer discovery by removing passwordless desktop administration and confining cups-browsed.
Changes:
- Replaces
cups-pdfwith Polkit-backed administration. - Runs
cups-browsedas a dedicated, sandboxed account. - Adds migration and security-focused tests.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
etc/cups/cups-browsed.conf |
Restricts discovery and isolates cache state. |
etc/systemd/system/cups-browsed.service.d/10-omarchy.conf |
Sandboxes the discovery daemon. |
etc/sysusers.d/omarchy-cups-browsed.conf |
Declares its dedicated system account. |
install/config/all.sh |
Runs printing configuration during setup. |
install/config/printing.sh |
Rewrites CUPS authorization settings. |
install/omarchy-base.packages |
Replaces cups-pdf with cups-pk-helper. |
migrations/1787815267.sh |
Migrates existing installations. |
test/acceptance.d/system-test.sh |
Adds live printing-security validation. |
test/shell.d/cups-hardening-test.sh |
Tests configuration and migration behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Run cups-browsed as a locked service account with a dedicated cache and a focused systemd sandbox. Restrict automatic queues to driverless IPP printers, remove wheel from passwordless CUPS administration, replace cups-pdf with Polkit-backed setup, and migrate existing systems safely. Reported-By: Erik Hunstad (Bad Sector Labs) Co-Authored-By: Daybreak Blue <[email protected]>
5648346 to
5c33688
Compare
…unning The migration recomputed whether cups-browsed was active at the start of every run, after an earlier run may already have stopped it. A run interrupted between that stop and the completion marker left the service down, and the retry that followed read it as inactive, skipped the restart, and wrote the marker anyway: printer discovery stayed off until the next reboot with no migration left to bring it back. Keying the restart to whether the unit is enabled survives the interruption, and reports not-enabled for a unit the user masked or disabled, which restarting would fail on and abort the migration short of its marker. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Co-Authored-By: Codex XHigh <[email protected]>
cupsd compares directive names with _cups_strcasecmp, so a hand-edited "systemgroup sys root wheel" is live configuration, but matching $1 against the canonical spelling skipped it and appended a second directive at the end of the file. parse_groups accumulates the groups of every SystemGroup directive it reads rather than replacing them, so both lines took effect and wheel kept the passwordless administration this is meant to remove, with the migration reporting success. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Co-Authored-By: Codex XHigh <[email protected]>
The username prompt already refuses the service accounts a desktop user must not claim, cups and lp among them. A user who took cups-browsed would get a primary group of that name, and the CUPS authorization written here puts that group in SystemGroup, handing that desktop user the passwordless administration the rest of this change removes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Co-Authored-By: Codex XHigh <[email protected]>
|
Reviewed by Claude Opus 5 in Claude Code, with an independent Codex XHigh second opinion. Three defects found and fixed; the commits are pushed to this branch. The change is sound and the premise holds — I pulled Arch's cups Pushed
Each fix carries a regression test, and each was proven by reverting the fix and watching its own test fail. What was checked
Codex ran at xhigh but hung and never wrote its report, so I harvested its reasoning from its log; two of the three defects above started as its leads. Its independence is not guaranteed here — its log shows it reading the reviewing session's own scratch directory. Left open, for a maintainer rather than for you The systemd drop-in and the new Two smaller ones, also left: Dropping cups-pdf and setting Waiting on the maintainer for the upgrade-ordering question above; nothing is blocked on you. |
Harden CUPS printer discovery (cherry picked from commit 169ad00)
Issue summary
Omarchy’s default printing configuration exposed two passwordless paths from ordinary desktop-user code execution to host root.
The provisioned desktop user belongs to
wheel, while CUPS configuredwheelas aSystemGroupand enabledPeerCred. Consequently, any process running in the user’s desktop session could silently perform privileged CUPS administration without a password or Polkit prompt.Two root-escalation paths were demonstrated:
queue, submit a job claiming to be
root, and cause an arbitrary program to execute as UID 0.cups-browsedran as root and stored predictable cache files under/var/cache/cups, which was writable by the account used for print filters. Passwordless CUPS administration allowed a command-bearing Foomatic queue to execute as that filter account, redirect a cups-browsed cache entry through a symlink, and cause the root daemon to write attacker-controlled metadata into a root-consumed configuration file.These printing issues turn any desktop-user code execution into silent host-root compromise. They were also used as the privilege-escalation stage of the reported Aether one-click chain: a crafted Aether theme first obtained user-session code execution, after which the default CUPS configuration provided root access without
sudo, a password, or an elevation prompt.This PR addresses the CUPS side of that chain. It removes the vulnerable CUPS-PDF backend, eliminates passwordless CUPS administration for
wheel, separates cups-browsed state from the print-filter account, and runs cups-browsed as a confined unprivileged service account.Actions
Harden Omarchy’s CUPS printer discovery while retaining automatic driverless IPP/AirPrint printer support.
cups-pdfand replace it withcups-pk-helperfor authenticated interactive printer administration through Polkit.cups-browsedas a locked, dedicated system user instead of root.cups-browsedgroup noninteractive CUPS administration throughPeerCred.wheelfrom CUPSSystemGroup, eliminating passwordless printer administration for every desktop process./var/cache/cups-browsedwith mode0750.CAP_NET_BIND_SERVICE.CreateRemotePrintersdirective with explicit driverless-only discovery policy.Discovery policy
This preserves modern driverless IPP/AirPrint discovery while preventing automatic queue creation for printers exported by legacy remote CUPS servers.
Service confinement
The service now runs with:
User=cups-browsed
Group=cups-browsed
CacheDirectory=cups-browsed
CacheDirectoryMode=0750
UMask=0027
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
RestrictSUIDSGID=yes
No ambient network capability is added.
Existing-system migration
The migration:
Custom CUPS system groups and inline comments are preserved. Symlinked privileged configuration files are refused.
Validation
The broader shell suite includes unrelated host-dependent failures caused by unavailable dependencies such as Lua and the sibling omarchy-iso checkout; the new CUPS test passes. A fresh-ISO
acceptance run remains pending because that checkout is unavailable in this environment.
Attribution
Reported-By: Erik Hunstad (Bad Sector Labs)