Skip to content

[WRONG BRANCH] fix(cli): shell-quote hub invite arguments - #489

Draft
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-hub-invite-vulnerability
Draft

[WRONG BRANCH] fix(cli): shell-quote hub invite arguments#489
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-hub-invite-vulnerability

Conversation

@luvs01

@luvs01 luvs01 commented Sep 12, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Prevent command injection when ocx hub invite prints a copy‑and‑run shell command that interpolates operator-supplied origins and client lists.
  • The previous hubInviteCommand returned WHATWG‑canonicalized origins verbatim, which permitted shell expansion (command substitution, brace expansion, etc.) when a user pasted the line into a shell.

Description

  • Add a robust single‑quote shell-quoting helper in src/cli/hub.ts and apply it to every dynamic value in hubInviteCommand so the pairing code, data URL, management URL, and --clients payload are emitted as safely quoted shell arguments.
  • Update tests/cli/hub-invite.test.ts to expect quoted arguments and add a focused regression asserting quoting for embedded single quotes, command‑substitution characters, and environment-style expansions.
  • No public behavior change to the invite workflow beyond safer printable output, and JSON envelope still contains the same fields (now with quoted command string).

Testing

  • Ran the focused test file with bun test tests/cli/hub-invite.test.ts and all 23 tests passed.
  • Ran bun run typecheck and bun run privacy:scan, both succeeded.
  • Ran the repository-wide bun run test; the focused hub-invite coverage remained green but the full parallel suite encountered unrelated worker panics in this container (existing unrelated test failures), so only the focused tests and CI‑required checks were relied on for verification.

Codex Task

@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 8750f9ba-50e2-4d69-af64-aa88dafc41ed


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-12T01:59:43.875033Z 85416af PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Sep 12, 2026
@github-actions

github-actions Bot commented Sep 12, 2026

Copy link
Copy Markdown

⏳ DRAFT

  • wrong target branch (main); retarget to dev.

What to do

  • Retarget this PR to dev — all contributions go to dev.

Its title has been prefixed with [WRONG BRANCH].
This pull request was already a draft. Its draft status will be preserved after every issue above is resolved.

@github-actions github-actions Bot changed the title fix(cli): shell-quote hub invite arguments [WRONG BRANCH] fix(cli): shell-quote hub invite arguments Sep 12, 2026
@github-actions
github-actions Bot marked this pull request as draft September 12, 2026 01:54

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 85416af59b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli/hub.ts
): string {
const clientsFlag = clients.length > 0 ? ` --clients ${clients.join(",")}` : "";
return `echo '${code}' | ocx connect ${dataUrl} --management-url ${managementUrl}${clientsFlag} --pairing-code-stdin`;
const shellQuote = (value: string): string => `'${value.replaceAll("'", `'"'"'`)}'`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Generate commands for the joining machine's shell

When the joining machine uses cmd.exe, single quotes do not protect shell metacharacters, so an accepted origin such as https://x&whoami&x causes the pasted invite line to execute whoami as a separate command. This can occur even when the hub itself runs Unix because the generated command is explicitly intended for another machine; the repository's existing CMD escaper confirms that & and | require escaping in src/update/npm-invocation.mjs:4-8. Emit or label a POSIX-only command and provide safe PowerShell/CMD variants rather than treating this quoting as shell-independent.

AGENTS.md reference: src/AGENTS.md:L20-L20

Useful? React with 👍 / 👎.

Comment thread src/cli/hub.ts
Comment on lines +232 to +233
const clientsFlag = clients.length > 0 ? ` --clients ${shellQuote(clients.join(","))}` : "";
return `echo ${shellQuote(code)} | ocx connect ${shellQuote(dataUrl)} --management-url ${shellQuote(managementUrl)}${clientsFlag} --pairing-code-stdin`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Synchronize the documented invite command

The emitted and JSON-envelope command now quotes every URL and client argument, but docs-site/src/content/docs/guides/remote-hub.md:328-331 and :384-389 still claim to show the exact printed line while using the old unquoted form, and the Korean translation retains it as well. Update the English example and translated copies so users are not taught the unsafe command shape this change removes.

AGENTS.md reference: src/AGENTS.md:L29-L29

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark bug Something isn't working codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant