Repository navigation
Harden omarchy-refresh-config against path traversal - #10413
Conversation
The escape only fires when the mirrored source exists, because the pre-existing "Not a shipped user config" check rejects everything else on the source side first. With no file at $OMARCHY_PATH/escape, three of the four cases passed against the unfixed script: deleting the */../* or the /* alternative from the guard left the suite green, and the assertion on $tmpdir/escape watched a path neither side of the copy ever names. Create the mirrored source, watch the destination the traversal would actually reach ($HOME/escape), and require the guard's own message for every rejected shape. Each of the five alternatives now fails a test when it is removed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
user_config_file is built by concatenating config_base, a slash and the argument, and is then tested against "$config_base"/*. Bash's * matches every possible suffix, including slashes and newlines, so both halves of that condition are false for every input: deleting the whole realpath block changes no outcome, and deleting the lexical guard above it leaves the traversal tests failing. realpath -m ran on the two bases only, never on the completed paths, so it never canonicalized anything a caller supplies. Saying otherwise in AGENTS.md promises containment the code does not provide, and the next reader would trust it. The lexical guard is the whole protection; say so, and say that symlinks under ~/.config are still followed, because resolving them would reject the dotfile setups that work today. Co-Authored-By: Codex XHigh <noreply@openai.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Reviewed by Claude Opus 5 with an independent second opinion from Codex at xhigh reasoning. The guard is correct and I have pushed two commits to this branch: The guard itself holds. I ran the real binary on a disposable Omarchy VM against No regression. All 41 files shipped under The tests did not test the guard — this is Codex's finding, and mutation on the worker confirmed it. The escape only fires when the mirrored source exists, because the pre-existing The I also rewrote the On severity, for whoever merges this: worth stating accurately in the description. Every caller in the repo passes a fixed literal, so there is no attacker-controlled path into this argument today; the only source of an arbitrary value is a person typing it, or an agent following Tests run on the worker VM: Where Codex agreed with the containment-check analysis I had already reached the same conclusion, and its independence is not currently guaranteed, so weigh that as agreement rather than confirmation. The vacuous-test finding was its own and is the reason Nothing else outstanding from my side; this is waiting on a maintainer. |
|
hey, this is already covered in #12718 (refresh-config path hardening). mind closing this as a duplicate? |
|
Re-checked at Reproduced on a disposable Omarchy VM. With Competing fix. #13214 makes the same change to the same base. I compared the two guards input by input with Codex at medium effort, and we reached the same answer: for absolute paths and every position of a Codex reviewed the diff and found no defects; where it agreed with conclusions I had already reached, its independence is not guaranteed. Nothing is waiting on the author. This now waits on a maintainer. |
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>
Problem
omarchy-refresh-configinterpolated its argument directly into both paths and only validated with[[ -e ]]on the source side:A name containing
..(e.g.../.bashrc,hypr/../../.ssh/config) resolves and copies outside~/.config— overwriting arbitrary user files (with a misleading backup) or, if the source side also escapes, copying arbitrary repo files into the home directory.AGENTS.mdeven documented this as known behavior.Change
..path segment up front withInvalid config path.realpath -mand verify they stay under~/.configand$OMARCHY_PATH/configbefore touching anything (covers symlink /a/../bedge cases the segment check could miss).AGENTS.mdthat described the old behavior.Tests
test/shell.d/refresh-config-test.sh:../escape,hypr/../../escape, and/etc/passwdare rejected; files outside.configare untouched.test/shell.d/refresh-config-test.shand./test/clipass. Full./test/allshows only the 6 pre-existing environmental failures (missing omarchy-pkgs checkout, no compositor/network) — verified identical on the clean base.Fixes #8423