Repository navigation
Quote install-app and install-font names like install-and-launch - #7843
Conversation
There was a problem hiding this comment.
Pull request overview
Prevents shell injection and quoting failures when app or font names contain apostrophes or shell syntax.
Changes:
- Shell-quotes display names and font families with
printf %q. - Adds regression coverage for spaces, apostrophes, and injection payloads.
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-install-app |
Safely quotes installation messages. |
bin/omarchy-install-font |
Safely quotes messages and font-family arguments. |
test/shell.d/desktop-entry-launch-test.sh |
Adds quoting and injection regression tests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| printf -v install_message '%q' "Installing ${name}..." | ||
|
|
||
| exec omarchy-launch-floating-terminal-with-presentation \ | ||
| "echo ${install_message}; omarchy-pkg-add ${packages}" |
There was a problem hiding this comment.
The %q for the name is correct.
I did a test of the apostrophe problem on v4-0-1. This change stops that problem.
The command puts
I did a test with the real program.
omarchy-install-app Vim "bash; /usr/bin/touch /tmp/omarchy-argv-audit-real/pwned-7843-packages"A terminal with the title Omarchy opened.
omarchy-pkg-add bash ran. The package bash is installed.
The ; token ran touch. A file was created.
After this change, this command can run a second command:
omarchy-install-app Vim 'vim; id'
Do this:
- Use %q for each package after you split the list.
- Or put the packages in "$@" in a constant script.
Do not put raw ${packages} next to a quoted name.
There was a problem hiding this comment.
Confirmed, and fixed in 1cc7e8c. Your first option is what landed: the list is split the way the unquoted expansion split it and each word is quoted on its own, so omarchy install app Vim 'vim; id' now hands vim; and id to omarchy-pkg-add as two arguments and runs nothing. It reads with -d '' rather than a plain read -a, because the plain form stops at the first newline and would silently drop the rest of a list.
Regression tests are in test/shell.d/desktop-entry-launch-test.sh, and each new assertion was checked by reverting the fix it covers and watching it fail — including one that pins the whole command string, since the substring assertions could not see a stray argument.
Checked by Opus 5 in Claude Code and by Codex XHigh, which reached the same conclusion about the package arguments independently.
🤖 Reply written by Opus 5 in Claude Code, posted from a human account.
|
|
||
| exec omarchy-launch-floating-terminal-with-presentation \ | ||
| "echo 'Installing ${name}...'; omarchy-pkg-add ${package} && sleep 2 && omarchy-font-set '${family}'" | ||
| "echo ${install_message}; omarchy-pkg-add ${package} && sleep 2 && omarchy-font-set ${family_arg}" |
There was a problem hiding this comment.
This problem is the same as in omarchy-install-app.
The family is quoted. The package is not quoted.
I did a test on a live session with omarchy-install-font from this change.
omarchy-install-font "JetBrainsMono" \
"bash; /usr/bin/touch /tmp/omarchy-argv-audit-real/pwned-7843-font-pkg; false" \
"JetBrainsMono Nerd Font"The ; token ran touch. A file was created.
The false token stopped omarchy-font-set. The font did not change.
The font is still JetBrainsMono Nerd Font.
omarchy-install-and-launch also uses omarchy-pkg-add ${packages}.
There was a problem hiding this comment.
Fixed in 1cc7e8c, and you were right about install-and-launch — it carried the same bare ${packages} and is included in the same commit.
One difference between the two: install-font's omarchy:args declares a single <package>, not a list, so there is no word-splitting to preserve and it is quoted whole rather than split. Your reproduction now arrives at omarchy-pkg-add as one argument and creates no file; the false never runs, so the font still gets set.
🤖 Reply written by Opus 5 in Claude Code, posted from a human account.
There was a problem hiding this comment.
Correction: the font does not still get set. Your payload is now one argument to omarchy-pkg-add. pacman fails, font-set is skipped, nothing extra runs.
The earlier test claimed the family still got set because the mock always exits 0. I dropped that and pinned the real && behavior: if pkg-add fails, font-set does not run.
There was a problem hiding this comment.
You are right, and my sentence above was wrong. pacman rejects the payload as a package name, the && short-circuits, and font-set never runs.
I checked your commit rather than taking it: flipping install-font's && to ; fails your new assertion, and the same mutation passes clean against the previous version of the test file. It catches a regression the old tests missed, so it stays as you wrote it.
🤖 Reply written by Opus 5 in Claude Code, posted from a human account.
The display name was quoted but omarchy-pkg-add's own arguments were still interpolated into the bash -c string raw, so `omarchy install app Vim 'vim; id'` ran id. The list has to reach the helper as several words, so it cannot be quoted whole: it is split the way the unquoted expansion split it and each word is quoted on its own. Reading with -d '' keeps a newline-separated list intact instead of dropping every package after the first, which plain read -a would. install-font's package is singular and is quoted whole, and install-and-launch carried the same flaw. Reported by acrogenesis in review of omacom#7843. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-Authored-By: Codex XHigh <noreply@openai.com>
The hostile-package case was asserting the family still got set, which only held because the mock always exits 0. pacman would reject that name and the && chain would skip font-set.
read -d '' always ends at EOF rather than on its delimiter, so it reports failure on every input. Under an inherited errexit the installers exited there and built no command at all. Reported by Codex XHigh in review of omacom#7843. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-Authored-By: Codex XHigh <noreply@openai.com>
|
Two commits have landed since the last note here, so here is what they are. 429bcfd is Adolanium's and it corrects a test of mine. My assertion claimed install-font still set the family after a hostile package, which only held because the mock always exits 0; with real pacman the 511f301 is mine and it fixes a bug I introduced in 1cc7e8c. Full suite is green at 2315 assertions across 185 files, plus test/cli. Both were found by a Codex XHigh review of the branch. Two things it raised are deliberately not here: an all-whitespace package list collapses to one empty argument, which no caller produces and which the existing empty guard already covers for real input; and 🤖 Written by Opus 5 in Claude Code, posted from a human account. |
* Quote install-app and install-font names like install-and-launch * Quote the package list too, not just the display name The display name was quoted but omarchy-pkg-add's own arguments were still interpolated into the bash -c string raw, so `omarchy install app Vim 'vim; id'` ran id. The list has to reach the helper as several words, so it cannot be quoted whole: it is split the way the unquoted expansion split it and each word is quoted on its own. Reading with -d '' keeps a newline-separated list intact instead of dropping every package after the first, which plain read -a would. install-font's package is singular and is quoted whole, and install-and-launch carried the same flaw. Reported by acrogenesis in review of #7843. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-Authored-By: Codex XHigh <noreply@openai.com> * Test that install-font skips font-set when pkg-add fails The hostile-package case was asserting the family still got set, which only held because the mock always exits 0. pacman would reject that name and the && chain would skip font-set. * Keep the installers working when errexit is inherited read -d '' always ends at EOF rather than on its delimiter, so it reports failure on every input. Under an inherited errexit the installers exited there and built no command at all. Reported by Codex XHigh in review of #7843. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-Authored-By: Codex XHigh <noreply@openai.com> --------- Co-authored-by: David Heinemeier Hansson <david@hey.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: Codex XHigh <noreply@openai.com> (cherry picked from commit 625c4a1)
…com#7843) * Quote install-app and install-font names like install-and-launch * Quote the package list too, not just the display name The display name was quoted but omarchy-pkg-add's own arguments were still interpolated into the bash -c string raw, so `omarchy install app Vim 'vim; id'` ran id. The list has to reach the helper as several words, so it cannot be quoted whole: it is split the way the unquoted expansion split it and each word is quoted on its own. Reading with -d '' keeps a newline-separated list intact instead of dropping every package after the first, which plain read -a would. install-font's package is singular and is quoted whole, and install-and-launch carried the same flaw. Reported by acrogenesis in review of omacom#7843. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-Authored-By: Codex XHigh <noreply@openai.com> * Test that install-font skips font-set when pkg-add fails The hostile-package case was asserting the family still got set, which only held because the mock always exits 0. pacman would reject that name and the && chain would skip font-set. * Keep the installers working when errexit is inherited read -d '' always ends at EOF rather than on its delimiter, so it reports failure on every input. Under an inherited errexit the installers exited there and built no command at all. Reported by Codex XHigh in review of omacom#7843. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-Authored-By: Codex XHigh <noreply@openai.com> --------- Co-authored-by: David Heinemeier Hansson <david@hey.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: Codex XHigh <noreply@openai.com>
install-app,install-fontandinstall-and-launchbuild a shell command string and hand it to the floating-terminal helper, which runs it throughbash -c. Everything interpolated into that string is parsed as shell, and none of it was quoted for that. The display name sat inside single quotes, so an apostrophe closed the quote and whatever followed ran as a command. The package arguments sat bare, so a;among them started a second command.omarchy-install-app "Foo's App" alphanever reachedomarchy-pkg-addat all —bash -cdied looking for a closing quote.omarchy install app Vim 'vim; id'installed vim and then ranid.Every value is now quoted with
printf %qbefore it enters the string, which is whatinstall-and-launchalready did for its echo text and its desktop id. The display name, the font family andinstall-font's package are single values and are quoted whole. The package list ininstall-appandinstall-and-launchhas to reachomarchy-pkg-addas several words, so it cannot be quoted whole: it is split the way the unquoted expansion split it and each word is quoted on its own. Reading it with-d ''keeps a newline-separated list intact instead of dropping every package after the first, which a plainread -awould truncate.The menu passes hardcoded package names, so none of this was reachable from the UI. But
omarchy install appandomarchy install fontare documented commands whose arguments are meant to be data, and they were not.🤖 Package quoting added and the change verified by Opus 5 in Claude Code. Reviewed by Codex XHigh.