Skip to content

Enforce mode 0600 on shell.json to protect plugin settings - #14770

Open
Sebo1411 wants to merge 4 commits into
omacom:quattrofrom
Sebo1411:fix/issue-14748-shell-json-permissions
Open

Sebo1411 wants to merge 4 commits into
omacom:quattrofrom
Sebo1411:fix/issue-14748-shell-json-permissions

Conversation

@Sebo1411

@Sebo1411 Sebo1411 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Problem

shell.json holds plugin settings and credentials (such as IPTV provider URLs with embedded usernames/passwords or token parameters), but the file could arrive with mode 0644 (world-readable) and stay that way:

  1. omarchy-refresh-config copies defaults with cp -f, inheriting the caller's umask (e.g. 022 -> 0644).
  2. Quickshell's FileView { atomicWrites: true } retains existing file permissions across writes.
  3. On systems where ~/.config / ~/.config/omarchy are accessible to other local users, sensitive settings could be read by other accounts.
  4. Fresh installs and omarchy-reinstall-configs copy shell.json from /etc/skel, where it could also arrive at 0644.

Fixes #14748

Solution

  1. bin/omarchy-refresh-config: when refreshing omarchy/shell.json, explicitly enforce mode 0600 on both the newly copied user config and any backup file created.
  2. bin/omarchy-shell-config: explicitly set mode 0600 on both the temporary staging file and $CONFIG_FILE in commit().
  3. bin/omarchy-provision-user: explicitly chmod shell.json to mode 0600 after copying /etc/skel during first installs.
  4. bin/omarchy-reinstall-configs: explicitly chmod shell.json to mode 0600 immediately after copying from /etc/skel.
  5. migrations/1791834933.sh: one-time migration that tightens existing ~/.config/omarchy/shell.json to mode 0600.
  6. Automated tests in test/shell.d/refresh-config-test.sh, test/shell.d/provision-user-test.sh, and test/shell.d/config-test.sh.

Verification

  • Unit test suite test/shell.d/refresh-config-test.sh passes (verifies 0600 mode on created file, replaced file, and backup file).
  • Unit test suite test/shell.d/provision-user-test.sh passes (verifies skel copy chmod to 0600).
  • Unit test suite test/shell.d/config-test.sh passes (verifies omarchy-shell-config commit() keeps mode 0600).

@greptile-apps

greptile-apps Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issue was found.

Summary

The PR sets owner-only permissions on shell.json during refresh, provisioning, config reinstall, and command-line edits. A migration tightens permissions for existing users.

  • Shell settings stay private across setup, refreshes, and saves.
  • Refresh failures now reach the caller as unsuccessful commands.

Reviews (13) · Last reviewed commit: "Merge quattro and retain shell.json prov..." · Reviewed by Greptile

Comment thread bin/omarchy-refresh-config Resolved
@jandrusk

Copy link
Copy Markdown

Important fix for #14748 — shell.json can hold plugin credentials, and cp under umask 022 plus FileView atomic writes keeping existing mode left it world-readable. Covering refresh-config, omarchy-shell-config commit(), and shell.qml persist/load is the right set.

BLOCKING coordination: this PR and #14774 both introduce migrations/1791573437.sh (shell.json 0600 vs Eve backlight). Please retimestamp one of them before merge.

Minor NIT: Quickshell.execDetached(["bash", "-c", "… chmod 0600 "$0" …", path]) is fine for paths without NULs; just confirming there is no synchronous chmod API in Quickshell that would avoid the shell round-trip.

@Sebo1411

Copy link
Copy Markdown
Contributor Author

Retimestamped the migration to migrations/1791834933.sh to avoid collision with #14774 and rebased on quattro.

Regarding the chmod API: Quickshell's QML layer currently exposes Quickshell.Io (FileView, Process) without a synchronous chmod method on FileView, which is why execDetached with chmod 0600 is used.

@Sebo1411

Copy link
Copy Markdown
Contributor Author

@greptile review

@Sebo1411
Sebo1411 force-pushed the fix/issue-14748-shell-json-permissions branch from 04df1a5 to 8fd22e6 Compare October 12, 2026 19:57
Comment thread test/shell.d/refresh-config-test.sh Resolved
@Sebo1411
Sebo1411 force-pushed the fix/issue-14748-shell-json-permissions branch from 8fd22e6 to e0602fd Compare October 12, 2026 21:38
@Sebo1411

Copy link
Copy Markdown
Contributor Author

@greptile review

@jandrusk jandrusk mentioned this pull request Oct 13, 2026
3 tasks done
@paulogeyer

Copy link
Copy Markdown
Contributor

+1, tested on my laptop (ASUS Vivobook, Intel Arc) at e0602fd, file-level tests only with a temporary HOME.

With this PR's checks run against stock quattro:

  • the migration file doesn't exist, so there's nothing to tighten a 0644 shell.json
  • omarchy-refresh-config omarchy/shell.json under umask 022 creates the file and its backup as 0644
  • the secureUserConfigFile wiring is missing from shell.qml

On this PR, merged cleanly onto current quattro (84cfb93):

  • the migration takes an existing 0644 shell.json to 0600
  • omarchy-shell-config commit and omarchy-refresh-config leave it and its backup at 0600
  • config-test.sh passes 37/37 (including the new 0600 check) and refresh-config-test.sh passes 5/5

I didn't run the quickshell runtime part of shell-json-permissions-test.sh. On the PR's own base (77bfaca), config-test.sh stops early at an unrelated PKGBUILD-coverage check against my local omarchy-pkgs checkout; on current quattro that check passes.

@omarchybot

Copy link
Copy Markdown
Collaborator

Not reviewed yet, so this comment gives no verdict on the pull request. Before any work starts, two models classify each item independently, and only an agreement counts. Claude Opus 5.5 read this as a bug fix for the world-readable shell.json reported in #14748. The second classifier, Codex Medium, did not run because omabot's daily allowance of second-opinion reviews was already used up. A classification only one model made is treated as unsettled, so no labels were added and nothing was run on a worker.

Next: the item is listed for the maintainer as unsettled at head e0602fd. The full review (reproducing the bug on a worker, running the suite, and a second opinion on the diff) happens when it is sent round again. Nothing is needed from you in the meantime.

@Sebo1411
Sebo1411 force-pushed the fix/issue-14748-shell-json-permissions branch from e0602fd to 4e33bee Compare October 30, 2026 17:38
Comment thread test/shell.d/config-test.sh Resolved
@Sebo1411
Sebo1411 force-pushed the fix/issue-14748-shell-json-permissions branch 2 times, most recently from f6458ae to 293737c Compare October 30, 2026 18:58
Comment thread test/shell.d/config-test.sh Resolved
@Sebo1411
Sebo1411 force-pushed the fix/issue-14748-shell-json-permissions branch from 293737c to d262c82 Compare October 30, 2026 19:31
@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review labels Nov 2, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at a25c99f against quattro 175e63b. The bug is real and the fix works. I pushed one commit to close two paths it missed.

Reproduced on a worker (an Omarchy VM, with this branch merged into current quattro), under umask 022:

  • Without the fix, omarchy-refresh-config omarchy/shell.json creates the file at 0644, and a replaced file and its .bak copy are both 0644. With the fix, all three are 0600.
  • The migration takes an existing 0644 shell.json to 0600.
  • The new refresh-config-test.sh case fails with the fix reverted and passes with it (5/5).

Pushed: a25c99f, Make shell.json private on fresh installs and config reinstalls. Two paths still left shell.json at 0644, and both are in this repository:

  • Fresh installs. New users get shell.json from /etc/skel, which is 0644 on the worker. omarchy-provision-user --first-install marks every shipped migration as done, so 1791834933.sh never runs for a new user. bin/omarchy-provision-user now chmods the file to 0600 after skel has been copied, before migrations are marked done.
  • omarchy-reinstall-configs. It runs cp -af /etc/skel/. ~/, which puts 0644 back over a file the migration already tightened, and the migration doesn't run again. bin/omarchy-reinstall-configs now chmods the file to 0600 straight after the copy.

provision-user-test.sh has a new case for the first path. It fails without the commit and passes with it. For the second path, I ran the copy-and-chmod lines on the worker against a scratch home: 0644 before the commit, 0600 after.

Tests on the worker: ./test/cli is green. These shell tests are green: config, refresh-config, provision-user, bar, menu, migrate-scope, platform-setup and notifications. Two tests each fail one case, first-run (git identity) and runtime-smoke (keepLoaded fixture IPC), and they fail the same way on plain quattro, so this change didn't cause them.

CI: the test job is red on one file, update-stay-awake-security-test.sh. This PR doesn't touch anything that test covers. The same file failed CI on another, unrelated PR tonight, and it passed 15/15 three times on a fresh worker at this head and on quattro. It needs a re-run.

Second opinion: Codex Medium and muse-wonder (via pi, thinking high) each reviewed the change twice. In the first round, both found the fresh-install and reinstall gaps above, and the commit fixes them. In the second round, both found nothing still open. Their independence is not guaranteed. They also noted the following, and I checked each point against the source:

  • The chmod 0600 lines in omarchy-shell-config's commit() change nothing today, because mktemp already creates 0600 files and mv keeps that mode. For the same reason, the new 0600 assertion in config-test.sh also passes on quattro. These lines would start to matter if Preserve shell.json and config migration file modes #12250 lands.
  • set -euo pipefail in omarchy-refresh-config breaks none of its callers. It does change behaviour, though: a failed backup or copy now stops the script instead of being ignored.
  • The path check only matches the spelling omarchy/shell.json, so ./omarchy/shell.json skips the chmod. No caller in this repository uses another spelling.

For the author: the PR description still lists a shell/shell.qml change and test/shell.d/shell-json-permissions-test.sh, but neither is in the diff any more. Could you update the description to match the change?

Waiting on the maintainer. #12250 changes the same commit() to keep a file's existing mode, while this PR makes it 0600. The two conflict, so whichever lands second needs reworking, and which policy shell.json follows is the maintainer's decision. Two smaller decisions are also theirs: whether to fix fresh installs here or by shipping shell.json as 0600 in packaging, and whether set -euo pipefail belongs in this PR.

Sebo1411 and others added 2 commits November 2, 2026 09:26
New users get shell.json from /etc/skel at 0644, and --first-install marks every shipped migration done, so the shell.json migration never runs for them. omarchy-reinstall-configs replays skel with cp -af, which puts 0644 back over a file the migration already tightened. Both now chmod it 0600 after the copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: muse-wonder High <noreply@meta.com>
@Sebo1411
Sebo1411 force-pushed the fix/issue-14748-shell-json-permissions branch from a25c99f to 51fdfd8 Compare November 2, 2026 08:27
@Sebo1411

Sebo1411 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Updated the PR description to match the current diff (reflecting the skel provisioning/reinstall paths and consolidated test coverage) and rebased onto latest quattro.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 3, 2026
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 17, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at 51fdfd8 after the rebase, against current quattro 3b36b9e. Both commits are unchanged from the last review, and the fix still works on today's base. Thanks for updating the description, which now matches the diff.

Reproduced on a worker (an Omarchy VM, with this branch merged into current quattro), under umask 022, with the fix reverted and then applied:

  • refresh-config-test.sh: the new shell.json cases fail with the fix reverted (mode 644) and pass with it, 5/5.
  • provision-user-test.sh: the new case fails with the fix reverted and passes with it, 4/4. The chmod still runs before first install marks migrations done, which matters since Mark migrations done with one touch on first install #18985 changed how that marking works.
  • 1791834933.sh takes an existing 0644 shell.json to 0600, does the same on a second run, and does nothing when there is no file. Its timestamp is older than migrations already on quattro, but omarchy-migrate checks each migration's own marker, so it still runs on existing installs.
  • The copy-and-chmod in omarchy-reinstall-configs leaves the file at 0600, and at 0644 with the fix reverted.

Tests on the worker: ./test/cli is green. These shell tests are green: config, refresh-config, provision-user, migrate-scope, migrate-notify, bar, menu, platform-setup and notifications. first-run and runtime-smoke each fail one case, and they fail the same way with the fix reverted. CI is green at this head.

Second opinion: Codex Medium and muse-wonder (via pi, thinking high) each reviewed this head. Neither found a defect that would affect a user, and their independence is not guaranteed. They confirmed every path that writes shell.json now ends at 0600, and that set -euo pipefail breaks none of omarchy-refresh-config's callers. Two of the new tests pass on quattro without the fix: the 0600 assertion in config-test.sh, because mktemp already creates 0600 files, and the copy-failure case in refresh-config-test.sh, because a failed cp is already the script's last command. I confirmed both on the worker. Neither test is wrong, but neither proves this change.

Waiting on the maintainer. The decisions from the last review still stand. #12250 rewrites the same commit() to keep a file's existing mode. If that version replaces this one, a 0644 shell.json stays 0644 through every later omarchy bar or omarchy plugin write, so whichever lands second needs to keep 0600 for this file. It is also the maintainer's call whether set -euo pipefail and its copy-failure test belong in this PR, and whether to keep the four call-site chmods or enforce the mode in one place. #17552 also edits the mktemp line in commit(). That is a small textual conflict, and it does not weaken this fix.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 18, 2026
Keep the shell.json permission coverage alongside the path traversal regression from omacom#10413. Both exercise omarchy-refresh-config and neither replaces the other.

Co-Authored-By: GPT-6.2 (high) <noreply@openai.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 18, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Pushed 8d868f2 to bring this branch onto quattro a5225d9. The conflict in refresh-config-test.sh is resolved with both the permission tests and #10413's traversal tests retained unchanged. GitHub now reports the branch merges cleanly.

Reproduced on a disposable Omarchy worker under umask 022: creating, replacing and backing up shell.json gives 0644 on base, 0600 on this head, and 0644 with the fix reverted. The provisioning test fails with its fix reverted. The migration is idempotent and leaves an absent file absent; the bounded reinstall copy/permissions check ends at 0600.

./test/cli and the focused config, refresh-config (6 cases), provision-user (5), migrate-scope, migrate-notify, bar, menu, platform-setup and notifications suites pass on the worker. first-run (Git identity with the synced checkout's invalid .git reference) and runtime-smoke (keepLoaded fixture IPC) each fail one case identically on current base. CI's test job is still running; i18n passed.

GPT-6.2 High in Codex reviewed the change. Opus 5.5 High and muse-wonder (via pi, thinking high) also reviewed this exact head and found no blocking runtime defect; both accepted the conflict resolution. Their independence is not guaranteed. I checked their findings: historical shell.json.bak.* files remain 0644 after the migration, while newly created backups become 0600. The copy-failure test is relevant: removing strict mode from this head makes it fail, because the final conditional masks a failed copy. The separate config-test.sh mode assertion still passes on base because mktemp already produces 0600.

This waits on the maintainer's decisions about the call-site strategy and generic helper's error handling, coordination with #12250's mode-preservation policy, and whether the migration should also secure historical backups. #17552 still touches the same writer for its separate atomic-rename fix.

@omarchybot

Copy link
Copy Markdown
Collaborator

CI now passes at unchanged head 8d868f25f124912e039e686faa0f132c94e5088a. GPT-6 in Codex (effort not exposed) checked the head, current base delta, comments and recorded evidence; no new tests or runtime review ran. The earlier Opus 5.5 High and muse-wonder (via pi, thinking high) review and worker results above still describe this code.

The classification refresh returned no usable answer from the second classifier, deepseek-v4p1-flash, so this pass is unsettled. The configured runtime reviewers both answered the health check; that does not supply the missing classification. Nothing further is needed from the author. This waits on classification and the maintainer decisions already listed.

@omarchybot omarchybot added bug Something isn't working and removed bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review labels Nov 18, 2026
Keep the private shell.json regression alongside the renamed omarchy-diagnose-crash skill and current provisioning checks.

Co-Authored-By: GPT-6 in Codex (effort not exposed) <noreply@openai.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 22, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Pushed 7c2067fd to resolve the provisioning test conflict against quattro 0bcf203d. The resolution keeps both the shell.json privacy assertion and the renamed omarchy-diagnose-crash skill checks. The branch now merges cleanly, and the new head is classified as a bug fix and labelled verified.

On a disposable Omarchy worker under umask 022, creating, replacing and backing up shell.json gives 0644 on base, 0600 on this head, and 0644 with the fix reverted. The provisioning and refresh privacy tests reject their reverted commands. The migration is idempotent and absent-safe; the bounded reinstall copy/chmod block finishes at 0600.

./test/cli passed. The full shell suite ran 438 files: four failed, and six contained skips. All four failures reproduce on the exact base: ASCII text width, the About logo animation, the provisioning console logo, and runtime-smoke's keepLoaded IPC fixture. The changed config, refresh and provisioning suites pass. CI now passes on this exact head.

GPT-6 in Codex (effort not exposed) reviewed and tested this head. Opus 5.5 High and muse-wonder (via pi, thinking high) also reviewed it and found no blocking runtime defect; their agreement is not guaranteed independent. Both accepted the conflict resolution. I rejected their claim that the copy-failure test is ineffective: removing strict mode from this head makes it fail. The writer's mode assertion still passes on base because mktemp already creates 0600 files. Greptile completed on this head at 5/5 with no new blocking finding; the older findings have been answered in their threads.

This remains with the maintainer for the call-site strategy, generic helper error-handling scope, redundant writer chmods/assertion, coordination with #12250's mode-preservation policy, and historical-backup scope. No further author action is requested while those choices are pending.

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

Labels

bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shell.json can be created 0644 and keeps that mode, exposing plugin secrets to other local users

4 participants