Skip to content

[WRONG BRANCH] fix: isolate namespaced exec authorization - #331

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

[WRONG BRANCH] fix: isolate namespaced exec authorization#331
luvs01 wants to merge 1 commit into
mainfrom
codex/propose-fix-for-namespaced-exec-vulnerability

Conversation

@luvs01

@luvs01 luvs01 commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Legacy shell-name normalization could be triggered by a namespaced MCP tool named exec, allowing unnamespaced exec_command/shell_command tool calls to be accepted even when the request did not declare a bare exec and thereby violating the request-local tool catalog boundary.

Description

  • Prevent adding a bare exec to the declared-name set when exec is declared inside a namespace, instead adding only the flattened namespaced wire name and tracking catalogs that contain a namespaced exec with a WeakSet.
  • When evaluating unnamespaced provider tool-call items, treat an echoed bare exec as authorized only if the catalog actually declared a bare exec, and avoid legacy-normalizing exec_command/shell_command in the namespaced-only case.
  • Add a regression test that asserts a namespaced-only exec declaration does not authorize exec_command or shell_command and adjust related expectations/comments accordingly.

Testing

  • Ran the focused unit tests with bun test tests/responses-undeclared-tool-guard.test.ts and the focused suite passed (65 tests passed).
  • Ran bun run typecheck and bun run privacy:scan, both completed successfully.
  • Ran bun run test in this environment and observed the majority of suites pass, though tests/native-profile-drain-server.test.ts timed out in this environment; the targeted guard behavior is validated by the focused tests and a local Bun 1.4.0 run of the focused suite.

Codex Task

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 50 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 4004cac8-2d45-40ef-80dc-ede64e15fe01

📥 Commits

Reviewing files that changed from the base of the PR and between ec51e42 and b77c01b.

📒 Files selected for processing (2)
  • src/server/responses-undeclared-tool-guard.ts
  • tests/responses-undeclared-tool-guard.test.ts

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.

@github-actions

Copy link
Copy Markdown

Deterministic PR hygiene checks passed.

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

github-actions Bot commented Aug 26, 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: isolate namespaced exec authorization [WRONG BRANCH] fix: isolate namespaced exec authorization Aug 26, 2026
@github-actions
github-actions Bot marked this pull request as draft August 26, 2026 01:51

@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: b77c01ba74

ℹ️ 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".

// declaration set, however: bare `exec` also authorizes legacy shell bridge aliases.
if (namespace) {
names.add(namespacedToolName(namespace, name));
if (name === "exec") CATALOGS_WITH_NAMESPACED_EXEC.add(names);

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 Preserve namespaced-exec authority when merging catalogs

When a routed request declares only a namespaced exec and the provider echoes its accepted bare child name, this WeakSet marker is lost in the production path: refreshUndeclaredToolGuard copies the collected names into the separate declaredWireToolNames set at src/server/responses/core.ts:3023-3027. Consequently CATALOGS_WITH_NAMESPACED_EXEC.has(declared) is false and the valid call is rejected with a 502 as undeclared. Carry this authority explicitly into the merged catalog (rather than attaching it to the temporary Set identity) and add coverage through handleResponses, which performs the merge.

AGENTS.md reference: src/AGENTS.md:L24-L26

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