Skip to content

Guard plugin-add against git transport-helper URLs (match theme-install) - #8067

Merged
dhh merged 2 commits into
omacom:quattrofrom
bastidotnet:fix/plugin-add-transport-helper-guard
Aug 25, 2026
Merged

dhh merged 2 commits into
omacom:quattrofrom
bastidotnet:fix/plugin-add-transport-helper-guard

Conversation

@bastidotnet

Copy link
Copy Markdown
Member

What

omarchy-plugin-add clones a user-supplied git URL without validating the URL's
transport, while omarchy-theme-install already guards against exactly this. This ports
that guard to plugin-add and adds a regression test.

Why

#7884 ("Stop an installed theme from running code") added a transport-helper guard to
omarchy-theme-install — it rejects ext::, fd:: and leading-dash option forms before
cloning — but did not touch omarchy-plugin-add. So plugin-add still relies entirely on
git's default protocol.ext.allow = never to stop a URL like ext::sh -c <cmd> from
running a command at clone time.

On a stock system that default holds and there is no exploit — Omarchy sets no protocol.*
override. This is therefore defense-in-depth, not a fix for a live RCE: it closes the
gap #7884 left in the sibling command, and removes a silent dependency on a git default the
project doesn't control. (#7622, which would accept plugin URLs from web pages, makes the
guard more relevant still.)

Change

  • Apply the finalised $url through the same guard used by theme-install, after both
    input sources (argv and gum input) and before git clone, reusing the existing fail
    helper.
  • Rejects ext:: / fd:: transport-helper forms and -* / --* option forms.
  • Still accepts https://…, git@host:org/repo.git, ssh://…, token-auth URLs, and
    scp-style IPv6 (git@[2001:db8::1]:org/repo.git).

Test

Adds a regression test to test/shell.d/plugin-add-test.sh asserting both the rejections
and that the legitimate URL forms above still pass the guard. git is stubbed, so no
network. Existing plugin-add suite passes; shellcheck -x clean on the changed script.

omarchy-plugin-add cloned a user-supplied git URL without the
transport-helper guard that omarchy-theme-install already applies
(added in omacom#7884, which did not touch plugin-add). Port that guard
(reject ext::/fd:: and leading-dash forms, keep https/ssh/scp-style
incl. IPv6) and add a regression test. Stock systems are unaffected
(git default protocol.ext.allow=never); this removes the silent
dependency on that default and aligns the two install paths.
Copilot AI balanced review requested due to automatic review settings August 24, 2026 16:09

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

Adds defense-in-depth URL validation to plugin installation, matching theme installation behavior.

Changes:

  • Rejects Git transport-helper and option-shaped URLs.
  • Adds regression tests using a stubbed Git executable.

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 2 changed files in this pull request and generated 1 comment.

File Description
bin/omarchy-plugin-add Adds pre-clone URL validation.
test/shell.d/plugin-add-test.sh Tests rejected and accepted URL forms.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +106 to +109
for bad in "-oProxyCommand=x" "--upload-pack=x"; do
rm -f "$clone_marker"
output=$(add_url "$bad") &&
fail "plugin add rejects an option-shaped URL: $bad" "$output"
The prior leading-dash cases only exercised the argv option parser, not
the guard (removing the guard's -* arm left them green). Drive a dash
value through the interactive gum prompt under a pty so the post-input
guard is actually covered; skip cleanly where util-linux script is
unavailable.
@bastidotnet

Copy link
Copy Markdown
Member Author

Good catch. The leading-dash cases were only exercising the argv option parser (-*) fail "unknown add option"), not the guard's -* arm — that arm is only reachable through the interactive gum input path, where argv parsing doesn't apply. Added a case that drives a dash value through that path under a pty (via util-linux script, the suite's existing idiom; gum is stubbed), so the guard is now actually covered. It skips cleanly where script isn't available. Verified by temporarily removing the -* arm — the new case goes red, confirming it tests the guard and not the parser. Kept the argv cases too, relabelled for what they check.

@dhh
dhh merged commit 30471bf into omacom:quattro Aug 25, 2026
omarchybot pushed a commit that referenced this pull request Aug 25, 2026
Backport of the plugin-add URL guard (PR #8067 by @bastidotnet, merged to
quattro as 30471bf) onto the v4-0-1 release branch.

omarchy-plugin-add cloned a user-supplied git URL without the transport-helper
guard omarchy-theme-install already applies. That guard arrived with #7884,
which is on this branch, but it never touched plugin-add -- so the sibling
command still leaned entirely on git's own protocol.ext.allow=never to keep a
URL like ext::sh -c <cmd> from running a command at clone time.

Stock systems are unaffected: Omarchy sets no protocol.* override, so the git
default holds and there is no live exploit here. This is defense in depth --
it closes the gap #7884 left in the sibling path and drops a silent dependency
on a default the project does not control. Reject ext::/fd:: and leading-dash
forms; https, ssh, scp-style and token-auth URLs still clone, including an
scp-style IPv6 host, which carries :: of its own.

Clean cherry-pick: both files are byte-identical to quattro, so merging v4-0-1
into quattro resolves without a conflict. The guard reads the same as the one
already in bin/omarchy-theme-install on this branch. test/shell passes: 186
files, with the plugin-add suite's new cases all running here -- including the
pty-driven prompt case, which is the only path that reaches the guard's
leading-dash arm.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_018DEMYa9UWtroz93DhMTtcV
omarchybot added a commit that referenced this pull request Aug 25, 2026
…lone from (backport of #8174)

Backport of the shared URL check (PR #8174, merged to quattro as 68ab12f) onto
the v4-0-1 release branch, on top of the #8067 backport it follows.

omarchy-theme-install and omarchy-plugin-add both clone a URL a stranger can
choose, and each carried its own copy of the rule that refuses a git option or a
transport helper before cloning. The rule now lives in omarchy-git-url-check and
both callers ask it: two copies of a security check drift, and the second copy
arrived four months after the first only because someone went looking for it.

That rule was also enforcing half of what it described. <helper>::<address> is
one of two shapes git resolves a remote helper from -- it also runs
git-remote-<scheme> for <scheme>://<address> whenever the scheme is not one it
connects itself, so ext::sh -c id and ext://sh -c id reach the same helper while
only the first was refused. Nothing exploitable follows on a stock system:
protocol.ext.allow defaults to never, and the :// spelling hands git-remote-ext
a command name it cannot exec. But a third-party helper installed on PATH is
reachable through the scheme form alone, and a guard is worth more when it
enforces the rule it states.

The :// shape cannot be refused the way :: is, because it is also how every
legitimate URL arrives, so the scheme is checked against the transports git
still connects itself: ssh git git+ssh ssh+git http https ftp ftps file.
git+ssh and ssh+git are on that list because they are spelled like a helper and
read as plain ssh; leaving them off would refuse a URL that clones today. ext
and fd are off it deliberately. A single colon is always scp-style ssh and a
bare path is always a path, so neither needs constraining.

The check fails closed: the callers read a non-zero status as a refusal, so a
missing omarchy-git-url-check refuses the URL rather than waving it through.

Clean cherry-pick on top of the #8067 backport: every file is byte-identical to
quattro, so merging v4-0-1 into quattro resolves without a conflict. test/shell
passes: 189 files, including the one this adds. test/cli passes, so the new
command's metadata is well-formed. Exercised the check here: https, scp-style,
ssh, git+ssh and scp-style IPv6 all pass, while ext:: ext:// fd:: fd:// and a
leading-dash form are refused, as is an uppercase EXT:// spelling.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_018DEMYa9UWtroz93DhMTtcV
nick1udwig pushed a commit to nick1udwig/omarchy that referenced this pull request Sep 9, 2026
…ll) (omacom#8067)

* Guard plugin-add against git transport-helper URLs

omarchy-plugin-add cloned a user-supplied git URL without the
transport-helper guard that omarchy-theme-install already applies
(added in omacom#7884, which did not touch plugin-add). Port that guard
(reject ext::/fd:: and leading-dash forms, keep https/ssh/scp-style
incl. IPv6) and add a regression test. Stock systems are unaffected
(git default protocol.ext.allow=never); this removes the silent
dependency on that default and aligns the two install paths.

* Test the plugin-add guard's leading-dash arm via the gum input path

The prior leading-dash cases only exercised the argv option parser, not
the guard (removing the guard's -* arm left them green). Drive a dash
value through the interactive gum prompt under a pty so the post-input
guard is actually covered; skip cleanly where util-linux script is
unavailable.
@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.

4 participants