Repository navigation
Refuse hook and state names that are paths - #8170
Conversation
There was a problem hiding this comment.
Pull request overview
Adds path-traversal guards for hook and state labels.
Changes:
- Rejects hook and state names containing
/or... - Adds regression coverage for valid names, traversal attempts, and state glob clearing.
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 1 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
bin/omarchy-hook |
Validates hook names before resolving them. |
bin/omarchy-state |
Validates state names before creating files. |
test/shell.d/hook-state-name-guard-test.sh |
Tests accepted and rejected names. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
omarchy-hook and omarchy-state set join a name straight into a path. A name with a slash, or a bare . or .., points outside the hooks or state directory. Every caller in the repo passes a fixed label, so this is a footgun guard for future callers, not a fix for anything that ships today. Names with dots in the middle (a..b) stay allowed. omarchy-state clear is untouched: find -name matches basenames only.
6c9b1b1 to
0a65b45
Compare
|
Reworked this after a second look.
|
|
3 improvements; Migration can overwrite administrator-authored PAM policy; treats any package-unowned file containing pam_fprintd, the gate, or the FIDO authfile as Omarchy-owned. Custom PAM files commonly satisfy that predicate. The rebuild then discards comments and all custom account, password, and session directives. Match exact known legacy layouts or replace only the known pam_unix lines while preserving everything else. Post-removal installations remain vulnerable. The same predicate requires a hardware-auth marker, but both removal commands delete those markers while leaving the bare four-line pam_unix override behind. Users who removed fingerprint/FIDO2 before upgrading are therefore skipped permanently. Recognize the exact markerless legacy layout too. Failed repairs are marked complete. migrations/1788256455.sh:49 ( omarchy/migrations/1788256455.sh Line 49 in 8a13eac |
|
I think this landed on the wrong PR. The migration, the PAM predicate, and the linked commit The three points look worth raising there, so you may want to move the comment over to #9873. |
|
Last change I can see:
|
The runner already rejects a slash, a bare . or .. The installer still joined the type into hooks/<type>.d before mkdir/cp, so a name nothing can run could still land on disk.
|
Done. omarchy-hook-install now refuses an empty name, a slash, or a bare . or .. before mkdir/cp, same as the runner. The regression test covers the installer too. |
…t already has quattro now refuses a hook or state name with a slash, or a bare . or .., in omarchy-hook and omarchy-state themselves (omacom#8170), and hook-state-name-guard-test.sh holds them to exit 2. Keeping this branch's guard ahead of those made the test fail: the guard is sourced through PATH, which that test does not set, and it exits 1 rather than 2. Both commands are already confined on quattro, so take quattro's versions and keep the shared guard for omarchy-toggle and omarchy-hyprland-toggle, the two that still climb out of their directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
omarchy-hookandomarchy-state setjoin a name straight into a path without looking at it:On the current code,
omarchy-hook ../../evilruns~/.config/evil, andomarchy-state set ../../escapecreates~/.local/escape. I checked that both happen before this change.This is a robustness fix, not a security one. Every caller in the repo passes a fixed label:
omarchy-updaterunsomarchy-hook post-update,omarchy-theme-setrunsomarchy-hook theme-set "$THEME_NAME"(the theme name is the argument, not the hook name),omarchy-channel-setand the migrations runomarchy-state set reboot-required. No user or network input reaches either command. The guard is there so a future caller that builds a name from something else cannot quietly write or run outside the directory.What changed:
/in it, or a name that is exactly.or... They exit 2 and print why on stderr..or..can leave the directory, so names likea..borv1..2stay valid. This matches howomarchy-webapp-installandomarchy-theme-setguard their names.omarchy-state clearis unchanged on purpose. It matches basenames throughfind -name, so a pattern can never walk out of the directory.Tests: new
test/shell.d/hook-state-name-guard-test.sh, 13 cases. A plain hook still runs, a plain state file is still created,a..bandv1..2are accepted,.and..and../xandsub/dirare refused with nothing created or run outside the directory, andclearstill honors glob patterns. Against the code before this change the test stops at the first refusal case. The other hook and state tests (monitor-state-test.sh,nvidia-kms-hook-test.sh) pass unchanged.