Skip to content

Quote install-app and install-font names like install-and-launch - #7843

Merged
dhh merged 4 commits into
omacom:quattrofrom
Adolanium:quote-install-app-font
Aug 30, 2026
Merged

dhh merged 4 commits into
omacom:quattrofrom
Adolanium:quote-install-app-font

Conversation

@Adolanium

@Adolanium Adolanium commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

install-app, install-font and install-and-launch build a shell command string and hand it to the floating-terminal helper, which runs it through bash -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" alpha never reached omarchy-pkg-add at all — bash -c died looking for a closing quote. omarchy install app Vim 'vim; id' installed vim and then ran id.

Every value is now quoted with printf %q before it enters the string, which is what install-and-launch already did for its echo text and its desktop id. The display name, the font family and install-font's package are single values and are quoted whole. The package list in install-app and install-and-launch has to reach omarchy-pkg-add 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 it with -d '' keeps a newline-separated list intact instead of dropping every package after the first, which a plain read -a would truncate.

The menu passes hardcoded package names, so none of this was reachable from the UI. But omarchy install app and omarchy install font are 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.

Copilot AI balanced review requested due to automatic review settings August 23, 2026 03:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread bin/omarchy-install-app Outdated
printf -v install_message '%q' "Installing ${name}..."

exec omarchy-launch-floating-terminal-with-presentation \
"echo ${install_message}; omarchy-pkg-add ${packages}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ${packages} into bash -c. The helper uses cmd="$*".

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:

  1. Use %q for each package after you split the list.
  2. Or put the packages in "$@" in a constant script.

Do not put raw ${packages} next to a quoted name.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread bin/omarchy-install-font Outdated

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}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

dhh and others added 3 commits August 23, 2026 22:19
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>
@omarchybot

Copy link
Copy Markdown
Collaborator

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 && chain short-circuits and font-set is skipped. It replaces that with a test that pins the real behaviour. I checked it by flipping install-font's && to ;: the new assertion fails, and the previous version of the test file passes the same mutation, so it catches a regression the old tests missed.

511f301 is mine and it fixes a bug I introduced in 1cc7e8c. read -d '' waits for a NUL that cannot appear in a bash string, so it always ends at EOF and always reports failure. Nothing breaks today because these scripts have no set -e, but under an inherited errexit — or the moment anyone adds set -euo pipefail — install-app and install-and-launch exited at that line and built no command at all, silently. It is guarded with || true and covered by a test that runs both scripts under SHELLOPTS=errexit; dropping either guard fails its own assertion. The comment on that line was also reworded, because -d '' does not keep newlines intact, it reads past them to EOF.

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 default/omarchy/omarchy-menu.jsonc:106 interpolates a theme directory name into a command string between single quotes, which is the same bug class but is live on main and wants its own change rather than being folded into this one.

🤖 Written by Opus 5 in Claude Code, posted from a human account.

@dhh
dhh merged commit 625c4a1 into omacom:quattro Aug 30, 2026
ryanrhughes pushed a commit that referenced this pull request Aug 30, 2026
* 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)
nick1udwig pushed a commit to nick1udwig/omarchy that referenced this pull request Sep 9, 2026
…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>
@emirb emirb added this to the 4.5 milestone Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants