Skip to content

[connectors] Track host-owned Codex Apps MCP provenance - #20649

Closed
mzeng-openai wants to merge 20 commits into
mainfrom
dev/mzeng/codex_apps_mcp_declare
Closed

mzeng-openai wants to merge 20 commits into
mainfrom
dev/mzeng/codex_apps_mcp_declare

Conversation

@mzeng-openai

@mzeng-openai mzeng-openai commented May 1, 2026 •

Copy link
Copy Markdown
Contributor

Why

MCP server names are routing labels, not a trustworthy ownership boundary. Connector-gateway behavior should only apply to the built-in Codex Apps MCP instance created by the host, not to an MCP server that merely has the same name or declares the same capabilities.

How provenance is determined

McpServerProvenance is host-assigned and runtime-only. MCP servers loaded from user/plugin config deserialize as UserConfigured; the only path that marks a server HostOwnedCodexApps is the host path that injects Codex Apps MCP at codex_apps using the ChatGPT backend /wham/apps endpoint. Because provenance is not serialized, cached Codex Apps tools are restamped as host-owned when loaded.

What changed

  • Add runtime-only McpServerProvenance and mark the host-injected Apps MCP as HostOwnedCodexApps.
  • Carry that provenance through managed MCP clients and emitted ToolInfo.
  • Switch connector-gateway behavior from raw server-name checks to provenance checks across auth/cache setup, connector discovery, tool exposure, and MCP tool-call approval handling.
  • Add regression coverage proving that a spoofed codex_apps server name is not treated as host-owned.

Testing

  • cargo test -p codex-mcp
  • cargo test -p codex-core mcp_tool_call

@mzeng-openai mzeng-openai changed the title [connectors] Enhance the way we identify connector gateway MCP [connectors] Track host-owned Codex Apps MCP provenance May 1, 2026
@mzeng-openai
mzeng-openai marked this pull request as ready for review May 1, 2026 23:22
@mzeng-openai
mzeng-openai requested a review from a team as a code owner May 1, 2026 23:22
@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ 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".

@viyatb-oai

Copy link
Copy Markdown
Contributor

Flagging one security concern from Viyat's security review automation.

The cached Codex Apps tool path appears to drop host-owned provenance. ToolInfo.server_provenance is skipped during serde, so when cached tools are loaded they come back with the default UserConfigured provenance. load_cached_codex_apps_tools then returns those tools without re-stamping them as HostOwnedCodexApps.

That matters because the exposure filtering treats host-owned Codex Apps tools differently: connector accessibility/enabled checks only apply when is_host_owned_codex_apps() is true. A cached app tool can therefore be model/tool-search visible as a normal MCP tool even when its connector should be disabled or inaccessible. The actual tool call path may recover once the live server is connected, but the model-visible surface is already wider than intended.

The fix I'd suggest: after deserializing the cache, set every cached Codex Apps ToolInfo.server_provenance = McpServerProvenance::HostOwnedCodexApps before running exposure filtering. Longer term, consider a cache DTO that does not serialize ToolInfo directly and converts back into ToolInfo with explicit provenance. A small regression should load a cached app tool for a disabled/inaccessible connector and assert build_mcp_tool_exposure does not expose it.

@mzeng-openai

mzeng-openai commented May 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Good catch. Cached Codex Apps tools now get restamped as HostOwnedCodexApps at the cache boundary, and I added a regression for the startup-cache load. The current manager path was already stamping before exposure, but this makes the invariant local so future direct cache reads cannot miss it.

@mzeng-openai
mzeng-openai requested a review from bolinfest May 4, 2026 16:04
…pps_mcp_declare

# Conflicts:
#	codex-rs/core/src/mcp_tool_call.rs
Comment thread codex-rs/codex-mcp/src/mcp/mod.rs Resolved
Comment thread codex-rs/codex-mcp/src/mcp/mod_tests.rs Resolved
@mzeng-openai
mzeng-openai requested a review from bolinfest May 4, 2026 23:41
Comment thread codex-rs/codex-mcp/src/mcp/mod.rs Resolved
Comment thread codex-rs/codex-mcp/src/mcp/mod.rs Resolved
Comment thread codex-rs/codex-mcp/src/mcp/mod.rs Resolved
Comment thread codex-rs/codex-mcp/src/mcp/mod.rs Resolved
…pps_mcp_declare

# Conflicts:
#	codex-rs/Cargo.lock
#	codex-rs/codex-mcp/Cargo.toml
#	codex-rs/codex-mcp/src/codex_apps.rs
#	codex-rs/codex-mcp/src/connection_manager.rs
#	codex-rs/codex-mcp/src/connection_manager_tests.rs
#	codex-rs/codex-mcp/src/mcp/auth.rs
#	codex-rs/codex-mcp/src/mcp/mod.rs
#	codex-rs/codex-mcp/src/rmcp_client.rs
#	codex-rs/core/src/connectors.rs
#	codex-rs/core/src/connectors_tests.rs
#	codex-rs/core/src/mcp_tool_call.rs
#	codex-rs/core/src/mcp_tool_exposure.rs
#	codex-rs/core/src/mcp_tool_exposure_test.rs
#	codex-rs/core/src/tools/spec_tests.rs
@mzeng-openai
mzeng-openai requested a review from bolinfest May 7, 2026 23:54
…pps_mcp_declare

# Conflicts:
#	codex-rs/Cargo.lock
#	codex-rs/codex-mcp/Cargo.toml
#	codex-rs/codex-mcp/src/connection_manager.rs
#	codex-rs/codex-mcp/src/connection_manager_tests.rs
#	codex-rs/codex-mcp/src/rmcp_client.rs
#	codex-rs/codex-mcp/src/tools.rs
#	codex-rs/core/src/connectors_tests.rs
#	codex-rs/core/src/mcp_tool_exposure_test.rs
#	codex-rs/core/src/tools/handlers/tool_search.rs
#	codex-rs/core/src/tools/spec_tests.rs
…pps_mcp_declare

# Conflicts:
#	codex-rs/core/tests/suite/tools.rs
@github-actions

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 14 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this May 29, 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