Skip to content

[Security] Treat command operands as literal values - #11495

Merged
ErikMelton merged 2 commits into
omacom:quattrofrom
lalvarezt:command-operands-as-literal
Sep 22, 2026
Merged

ErikMelton merged 2 commits into
omacom:quattrofrom
lalvarezt:command-operands-as-literal

Conversation

@lalvarezt

Copy link
Copy Markdown
Contributor

Some helper scripts pass command-line values to other programs without explicitly ending the option list. If a value starts with -, such as --help, it can be interpreted as a flag instead of the value the user intended. The helper may then show help, fail, or act on the wrong input.

One example in omarchy-pkg-add: omarchy-pkg-add --hookdir /tmp/attacker-hooks innocuous-package was forwarded to root pacman as pacman -S --noconfirm --needed --hookdir /tmp/attacker-hooks innocuous-package. Pacman treated --hookdir as an option and could run a selected hook during the package transaction, even though the helper later returned an error. With --, the call becomes pacman -S --noconfirm --needed -- --hookdir /tmp/attacker-hooks innocuous-package, so the value is treated as a package operand instead.

@lalvarezt
lalvarezt force-pushed the command-operands-as-literal branch from 1d971f3 to b72d7e5 Compare September 12, 2026 15:57
@ErikMelton

Copy link
Copy Markdown
Member

The hardening looks correct, but this PR currently breaks the repository’s shell test suite. The following tests pass on quattro and fail on this PR:

  • test/shell.d/fingerprint-driver-migration-test.sh
  • test/shell.d/fingerprint-package-test.sh
  • test/shell.d/menu-guards-test.sh

Their pacman stubs and exact argv expectations still assume the old forms:

  • pacman -Q <package>
  • pacman -S ... <packages>

They need to accept the new delimiter forms:

  • pacman -Q -- <package>
  • pacman -S ... -- <packages>

@lalvarezt

Copy link
Copy Markdown
Contributor Author

The hardening looks correct, but this PR currently breaks the repository’s shell test suite. The following tests pass on quattro and fail on this PR:

😲 my bad, that's what I get for not running the full suite. Fixing it

@ErikMelton
ErikMelton merged commit a4dd253 into omacom:quattro Sep 22, 2026
omarchybot added a commit that referenced this pull request Oct 1, 2026
sunshine-bin and sunshine-git provide and conflict with sunshine without a version, so pacman -Q sunshine names them, the version strip misses, and the migration tried to replace them with the repo package. --noconfirm declines the conflict and pacman exits 1, so the migration failed on every update even for an already patched provider. The notice is worded for a provider that may already be patched, since its version is not comparable to the repo package's.

The test's pacman stub now also accepts the -- that omarchy-pkg-present passes on quattro since #11495; without it the test failed once merged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
omarchybot added a commit to d-zalewski/omarchy that referenced this pull request Oct 3, 2026
quattro now passes `--` before the path on every editor launch (omacom#11495), so the --sudo fallback does the same and the tests expect it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ryanrhughes pushed a commit that referenced this pull request Oct 16, 2026
Treat command operands as literal values

(cherry picked from commit a4dd253)
ryanrhughes added a commit that referenced this pull request Oct 16, 2026
omarchy-pkg-add passes -- now that #11495 is on this branch, so the fixture
matches quattro again.
ryanrhughes added a commit that referenced this pull request Oct 16, 2026
The pacman fixture hunks of #14259, needed now that #11495 is on this branch.

(cherry picked from commit 0e7d6c2)
@emirb emirb added this to the 4.0.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.

3 participants