Skip to content

fix(plugins): resolve native MCP header environment references - #160244

Open
Patrick-Erichsen wants to merge 1 commit into
codex/fix-mcp-dcr-registration-retryfrom
codex/fix-native-mcp-header-env
Open

Patrick-Erichsen wants to merge 1 commit into
codex/fix-mcp-dcr-registration-retryfrom
codex/fix-native-mcp-header-env

Conversation

@Patrick-Erichsen

@Patrick-Erichsen Patrick-Erichsen commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Native plugin MCP headers currently retain literal environment references, preventing built-in provider adapters from using user-supplied credentials safely.

User Impact

Enabled native plugins resolve header references using the existing config substitution grammar. Missing or empty required variables omit that server and produce a redacted diagnostic; other servers remain available.

Why This Change Was Made

Resolve credentials at the existing native manifest boundary instead of adding per-company runtime code. This applies only to native MCP headers, preserving existing bundle format and command/URL behavior. Static inspection may retain authored references after validating required variables; runtime transports receive resolved headers.

Evidence

  • Plugin-loader tests cover resolved credentials, escaping/fallbacks, missing variables, sibling retention and redacted diagnostics. Existing bundle merge and disabled-server tests pass.
  • Real native GitHub plugin resolved a user credential in memory, authenticated, listed 45 tools and read the public OpenClaw LICENSE with get_file_contents (SHA ebaebf7c416761a32f932ad70ebe5d1d2e214f68). No credential was written to proof files.
  • Missing-key and redaction tests use simulated values. This does not certify third-party provider security.

Stack-head validation

  • node scripts/check-changed.mjs --base 1fe560c198c2917154e2e1b130b0df3352ac5114 passed: static guards, dependency/lock checks, generated metadata, all typecheck graphs, dead-code scans, lint and runtime import cycles.
  • pnpm test src/agents/mcp-oauth.test.ts src/plugins/bundle-mcp.test.ts src/agents/bundle-mcp-config.test.ts src/cli/mcp-cli.test.ts src/cli/mcp-cli.plugins.test.ts src/cli/mcp-cli.oauth.test.ts src/plugins/contracts/package-manifest.contract.test.ts src/plugins/contracts/extension-runtime-dependencies.contract.test.ts --maxWorkers=1 passed: 729 tests / 8 files / 5 routed shards in 420.34s. The new CLI plugin suite took 54.31s including cold transformation (3 tests); the infra suite took 200.74s (67 tests). Hosted CI timing was not yet available.
  • Six additional Doctor contract/closure tests passed in the full check. Fresh P2 review findings about Typeform/Customer.io regions were addressed through documented existing overrides and live regional registration proof.

Package and upgrade proof

Validated stack head 5859d7c3d184e80cfed01304a93681ff69d64036 on macOS arm64 / Node 24.19.0:

  • Canonical node scripts/package-openclaw-for-docker.mjs --allow-unreleased-changelog --output-dir .artifacts/claw-723/package passed (19m47.6s), including declaration builds, UI build, package inventory and extracted runtime import-graph checks.
  • Built openclaw-2026.9.6.tgz, 99,082,240 bytes, SHA-256 0ee3ab0c8d43e777431ce557797c9609dbeb10bef9fbaf40a0d5dcf4954bcb04. All 35 compiled entries are present; packed manifests match source exactly.
  • Fresh isolated npm install: plugins list --json finds all 35 under the installed package, origin bundled, disabled. Enabling GoDaddy/Excalidraw exposes native MCP servers without manual config; live mcp probe returns 2/5 tools. Authenticated GitHub returns 45 tools; output is redacted. Missing-key fail-closed behavior and regional endpoint overrides pass. npm lifecycle-script approvals are limited to this disposable fixture; no user/global npm policy changed.
  • Real published-driver cell: registry [email protected] ran update --tag <candidate.tgz> --yes --json --no-restart --timeout 900. Result status: ok, installed build 2026.9.6-5859d7c3d184-2026-09-28T06-43-34.310Z; maintained upgrade-survivor helper verified baseline, candidate and installed application-byte identities. Existing disabled MCP config and enabled memory-core survived unchanged; all 35 additions remain disabled.
  • The updater's migration rehearsal, config validation, plugin resolution, isolated Gateway canary, Doctor and post-plugin lint passed. Its nonfatal warnings described deferred model-retirement repair, loopback-only hosting and deliberately skipped service management for isolated state. No personal Gateway restart or production release. Upgrade endpoint is a disabled synthetic fixture; separate provider calls above are live.

An earlier package attempt correctly refused a namespace change caused by concurrent generated-doc work. The final build ran after generation and checks finished, on stable inputs. OAuth consent/account tools and ten additional key-service accounts remain unverified; discovery-only inclusion is the approved milestone.

Stack order

  1. fix(mcp): retry typed OAuth client metadata errors #160243 — typed OAuth registration retry
  2. fix(plugins): resolve native MCP header environment references #160244 — native MCP header environment resolution
  3. fix(mcp): discover enabled plugin servers in the CLI #160245 — enabled plugin MCP discovery in the CLI
  4. feat(plugins): add opt-in company MCP built-ins #160246 — 35 opt-in company built-ins

Review only; no merge or release is authorized.

Hosted CI follow-up

Hosted CI is not green. Local validation above passed on the pinned stack; GitHub's later merge-ref/stack runs reported:

  • Bottom OAuth PR: run 36391006397 failed four unchanged service-operation-lock.retained-custody.test.ts cases (missing, unknown-phase, unknown-version, relative-source); sibling jobs were cancelled. The newer merge base includes upstream b107d4af, whose handoff-store refactor makes release() throw for malformed custody where the unchanged test expects false. The OAuth PR changes neither that owner nor its tests. A local replay of the same test-group order on pure upstream c136ec631464 reproduced all four failures with no CLAW-723 code present: 900 passed, 4 failed, 5 skipped across the same 18-file group in 112.43s (macOS; hosted run was Linux). The first archive attempt stopped before tests because scoped dependency links were missing; the corrected prerequisite setup is the reproducing run.
  • Header and built-in layers: run 36391038048 and run 36391101586 stop in preflight because the existing changed-owner planner generates 169/148 Node rows against its 130-row cap. No tests execute in those runs. Upstream a08479ac already fixes that planner handoff without raising the limit or dropping coverage; it is newer than this validated stack base.
  • The CLI layer's hosted checks were still processing with no failed checks at the follow-up read. No workflow dispatch, rerun, policy bypass or push merely to obtain green was performed.

These hosted outcomes remain review/landing context, not passing evidence. No merge is authorized.

@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: M labels Sep 28, 2026
@Patrick-Erichsen Patrick-Erichsen changed the title fix: resolve environment credentials for native MCP plugins fix(plugins): resolve native MCP header environment references Sep 28, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 28, 2026
@clawsweeper

clawsweeper Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 28, 2026, 3:40 AM ET / 07:40 UTC (Revision 2).

ClawSweeper review

What this changes

The branch resolves environment references in enabled native plugin MCP headers, skips servers with missing required values, and adds documentation and loader tests.

Merge readiness

⛔ Blocked before merge - 6 items remain

This PR remains useful because current main does not resolve native plugin MCP header references. The earlier security finding remains on the unchanged head: resolving a credential before Codex CLI projection places its value in a process argument.

Priority: P2
Reviewed head: 9105520cc179fae991856a208ee9b4d9434f55d3

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The loader behavior has focused tests and a reported live call, but the credential exposure and missing final-boundary proof make this head unready to merge.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: Authority-chain proof required: The PR body reports successful authenticated GitHub MCP use on a later stack head, but supplies no final Codex CLI spawn trace showing that an allowed call works while a local process-argument observer cannot see the credential. Add redacted terminal or log evidence for that boundary, removing private values, IP addresses, and endpoints; updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🧂 unranked krab (1/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Authority-chain proof required: The PR body reports successful authenticated GitHub MCP use on a later stack head, but supplies no final Codex CLI spawn trace showing that an allowed call works while a local process-argument observer cannot see the credential. Add redacted terminal or log evidence for that boundary, removing private values, IP addresses, and endpoints; updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 11 items Introduced credential materialization: The native loader substitutes each header from process.env and normally returns resolved headers to consumers.
Codex CLI argument sink: Codex projection serializes MCP headers into a -c mcp_servers argument; the CLI runner sends its arguments to the process supervisor.
Existing safe Codex projection: An authored header reference maps to bearer_token_env_var or env_http_headers; a literal resolved value instead maps to http_headers.
Findings 1 actionable finding [P1] Keep native header credentials out of Codex CLI arguments
Security Needs attention Credential value in process arguments: The new loader materializes a header before Codex converts MCP configuration into a command-line override, making the value available to process-argument observers.

How this fits together

Enabled plugin manifests supply MCP server definitions to OpenClaw's agent runtime. The loader combines them with operator configuration before a local transport or coding harness connects to the server.

flowchart LR
A[Enabled plugin] --> B[Manifest MCP headers]
B --> C[Environment resolver]
C --> D{Required value available?}
D -->|Yes| E[Agent or coding harness]
D -->|No| F[Skip server and warn]
E --> G[MCP server connection]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Authority-chain proof required: The PR body reports successful authenticated GitHub MCP use on a later stack head, but supplies no final Codex CLI spawn trace showing that an allowed call works while a local process-argument observer cannot see the credential. Add redacted terminal or log evidence for that boundary, removing private values, IP addresses, and endpoints; updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Keep native header credentials out of Codex CLI arguments (P1) - Resolving a native header here turns an environment reference into a literal value. Codex projection then serializes that value into -c mcp_servers=..., exposing the credential through process arguments. Preserve environment-backed projection for this path and cover the final spawn arguments.
  • Resolve security concern: Credential value in process arguments - The new loader materializes a header before Codex converts MCP configuration into a command-line override, making the value available to process-argument observers.
  • Resolve merge risk (P1) - Resolved native MCP header credentials can enter Codex CLI -c arguments and become visible through local process inspection.
  • Complete next step (P2) - Repair the Codex CLI credential projection and add redacted final-argument and authenticated-call proof before merge.
  • Improve patch quality - Preserve environment-backed headers through Codex CLI projection and show redacted final-argument evidence for an allowed call and the nearest unauthorized observer.

Findings

  • [P1] Keep native header credentials out of Codex CLI arguments — src/plugins/bundle-mcp.ts:470
  • [high] Credential value in process arguments — src/plugins/bundle-mcp.ts:470
Agent review details

Security

Needs attention: Native header substitution can put environment-sourced credentials into Codex CLI process arguments.

PR surface

Source +57, Tests +147, Docs +2. Total +206 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 58 1 +57
Tests 1 148 1 +147
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 208 2 +206

Review metrics

Metric Value Why it matters
Production versus test delta production +57 net lines, tests +147 net lines The production growth is concentrated in native header handling, with tests for substitution and missing-value behavior.

Merge-risk options

Maintainer options:

  1. Repair Codex header projection (recommended)
    Preserve environment indirection in Codex CLI arguments and show an authenticated call plus a redacted final spawn trace without credential values.

Technical review

Best possible solution:

Keep native header references environment-backed through Codex projection, while retaining the loader's missing-value diagnostics and operator overrides.

Do we have a high-confidence way to reproduce the issue?

Yes. The source establishes a path from a native header reference to a literal Codex CLI argument; this read-only review did not execute a subprocess.

Is this the best way to solve the issue?

No. Resolving references at the native manifest boundary is coherent for in-process transports, but Codex needs its existing environment-backed header projection preserved.

Full review comments:

  • [P1] Keep native header credentials out of Codex CLI arguments — src/plugins/bundle-mcp.ts:470
    Resolving a native header here turns an environment reference into a literal value. Codex projection then serializes that value into -c mcp_servers=..., exposing the credential through process arguments. Preserve environment-backed projection for this path and cover the final spawn arguments.
    Confidence: 0.95

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against ff8c752d852f.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The change addresses a bounded plugin integration problem, but its current Codex projection needs repair before merge.
  • merge-risk: 🚨 security-boundary: The introduced substitution can expose environment-sourced credentials in Codex CLI process arguments.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: The PR body reports successful authenticated GitHub MCP use on a later stack head, but supplies no final Codex CLI spawn trace showing that an allowed call works while a local process-argument observer cannot see the credential. Add redacted terminal or log evidence for that boundary, removing private values, IP addresses, and endpoints; updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. No stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [high] Credential value in process arguments — src/plugins/bundle-mcp.ts:470
    The new loader materializes a header before Codex converts MCP configuration into a command-line override, making the value available to process-argument observers.
    Confidence: 0.95

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • fuller-stack-dev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • joshavant: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-28T07:28:44.466Z sha 9105520 :: needs real behavior proof before merge. :: [P1] Keep native header credentials out of Codex CLI arguments

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

This branch has not been deployed

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

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: M stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant