Skip to content

fix(config): skip merging fallback servers when managed servers exist - #10

Closed
lydakis wants to merge 1 commit into
mainfrom
codex/propose-fix-for-cli-command-shadowing-vulnerability
Closed

fix(config): skip merging fallback servers when managed servers exist#10
lydakis wants to merge 1 commit into
mainfrom
codex/propose-fix-for-cli-command-shadowing-vulnerability

Conversation

@lydakis

@lydakis lydakis commented Mar 23, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Prevent untrusted fallback files (e.g. project-scoped .mcp.json) from injecting server names that can shadow internal CLI commands and cause unintended tool execution when the user already has managed servers configured.
  • Restore the original safety boundary where fallback discovery is only used for zero-config onboarding and does not override or extend an explicit managed config.

Description

  • Added an early return in MergeFallbackServersForCWD to skip loading/merging fallback sources when cfg.Servers is non-empty (internal/config/fallback.go).
  • Updated the merge test to assert that when managed servers are present no discovered fallback servers are added (TestMergeFallbackServersKeepsManagedOnlyWhenConfigured in internal/config/fallback_test.go).
  • Preserved existing behavior for empty configs and explicit FallbackSources overrides so existing onboarding and configured-source semantics remain unchanged.

Testing

  • Ran go test ./internal/config -run MergeFallback -count=1, which passed.
  • Ran go vet ./... and go build ./..., both of which passed.
  • Ran go test ./... which fails in this environment due to pre-existing internal/config Codex-related tests (TestLoadCodexConfigFileAddsCodexAppsServerFromAuthFile and TestLoadCodexConfigFileCodexAppsUsesConnectorsTokenEnv) that are unrelated to the fallback merge change.

Codex Task

@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: 241f6d36f0

ℹ️ 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 on lines +98 to +99
if len(cfg.Servers) > 0 {
return nil

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 Honor explicit fallback_sources when managed servers exist

When a config defines both at least one managed servers.* entry and an explicit fallback_sources list, this early return prevents MergeFallbackServersForCWD from reading those user-specified sources at all. That regresses partial-adoption setups such as “keep github in mcpx config, but import everything else from /tmp/legacy.json”: the old collision logic already ensured managed entries won per-name, so skipping the entire merge drops unrelated discovered servers unnecessarily.

Useful? React with 👍 / 👎.

lydakis added a commit that referenced this pull request Aug 28, 2026
…shadowing (#36)

* fix: stop CWD config discovery, listing probes, and fallback command shadowing

Rewrite the still-valid security/correctness fixes from stale PRs #12, #11, and #10 onto current main. Bare mcpx stays config-only, project-local .mcp.json is no longer auto-imported, and fallback merge is skipped when managed servers already exist.

* fix: align fallback watch with managed config and keep named virtual servers

Skip merge and source watching only when config.toml has MCPXConfig origins, not whenever cfg.Servers is non-empty. Filter reserved CLI names from fallback discovery, and resolve explicit --help / shim install targets via list_tools so Codex virtual servers still work.
@lydakis

lydakis commented Aug 28, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #36 (landed on main). Closing this stale March branch.

@lydakis lydakis closed this Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant