Skip to content

fix(lsp): bundle LSP servers inherit Gateway secrets - #179415

Merged
VACInc merged 5 commits into
openclaw:mainfrom
VACInc:fix/lsp-server-env-scrub
Oct 22, 2026
Merged

VACInc merged 5 commits into
openclaw:mainfrom
VACInc:fix/lsp-server-env-scrub

Conversation

@VACInc

@VACInc VACInc commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Summary

High Level TLDR

Language servers that plugin bundles declare in .lsp.json (or manifest lspServers) were started with the Gateway's whole environment: provider API keys, Gateway and hook tokens, secret-manager credentials, anything loaded from .env. Bundle MCP stdio servers, which use the same command/args/env launch config, already start from a short allowlist. This change gives LSP servers the same allowlisted base (plus locale, temp, XDG and toolchain locations language servers read) and keeps the server's own env working. Because some language servers relied on other inherited variables (proxies, CA bundles, virtualenvs), the Gateway now names those variables once per server when it starts one, and openclaw doctor names them for configured bundle LSP servers, with how to pass each one.

What Problem This Solves

Fixes: every bundle-declared LSP server holds a copy of the Gateway's secrets in its process environment for its lifetime, readable from /proc/<pid>/environ by anything running as the same user and inherited by anything the language server starts (build tools, compilers, project scripts).

User Impact

Bundle LSP servers no longer receive Gateway credentials. Tools and behavior are unchanged: a real stdio LSP server started through the bundle LSP runtime still initializes, its lsp_* tool still answers, and its configured env still applies. A language server that relied on some other inherited Gateway variable must now get it another way; the Gateway log and openclaw doctor name the affected variables (names only), and the docs list exactly what is inherited and how to pass the rest.

Upgrade note

  • Bundle LSP servers now start with: HOME, LOGNAME, PATH, TERM, USER (standard system variables on Windows); LANG, LANGUAGE, LC_*, TZ, TMPDIR, TMP, TEMP; the XDG_* base directories; GOROOT, GOMODCACHE, GOBIN, JAVA_HOME, RUSTUP_HOME, RUSTUP_TOOLCHAIN; then the server's own env. Everything else in the Gateway environment is no longer passed.
  • Newly withheld compared with before this change (they were inherited before): proxy variables (HTTP_PROXY, HTTPS_PROXY, ALL_PROXY, NO_PROXY, lowercase forms), CA bundle variables (SSL_CERT_FILE, SSL_CERT_DIR, NODE_EXTRA_CA_CERTS, REQUESTS_CA_BUNDLE, CURL_CA_BUNDLE), GRADLE_USER_HOME (the host exec env policy lets a child inherit it but refuses it in a server's env), and any variable outside the host exec env policy lists (for example CARGO_TARGET_DIR, DOTNET_ROOT, ANDROID_HOME, MAVEN_HOME).
  • Unchanged (already withheld before this change by the host exec env policy): GOPATH, CARGO_HOME, GOFLAGS, GOPROXY, GOPRIVATE, VIRTUAL_ENV, CONDA_PREFIX, PYTHONPATH, NODE_OPTIONS, NODE_PATH.
  • What operators see: one Gateway warning per server (repeated only if the server name or the withheld names change), for example bundle-lsp: server "gopls" starts without these Gateway environment variables. DOTNET_ROOT: add to the server's "env" in its bundle .lsp.json if it needs them. HTTPS_PROXY, VIRTUAL_ENV: refused by the host exec env policy, also in "env"; a server that needs them must set them itself (for example, a wrapper script as its "command"). See https://docs.openclaw.ai/plugins/bundles#lsp-server-environment. openclaw doctor prints a "Bundle LSP environment" note with the same split per configured server, reading both the doctor process and the installed Gateway service environment. Only a curated list of commonly needed, non-secret names is reported; values are never printed and names that look like secrets (TOKEN, KEY, SECRET, PASSWORD, CREDENTIAL, AUTH, COOKIE, SESSION) are skipped.
  • What to do: for a name the policy allows, add it to that server's env in the bundle .lsp.json. For a name the policy refuses in env too (proxy, CA bundle, VIRTUAL_ENV, Go settings), point the server's command at a wrapper script that sets it. Docs: https://docs.openclaw.ai/plugins/bundles#lsp-server-environment

Root Cause

  • Before behavior: with four synthetic canaries in the Gateway process environment, a Claude-format bundle declaring a stdio LSP server was started by createBundleLspToolRuntime(); the child's /proc/<pid>/environ and the server's own answer through the lsp_hover_* agent tool both showed all four canaries (output below).
  • Code: spawnLspServerProcess() in src/agents/agent-bundle-lsp-process.ts builds the child env with sanitizeHostExecEnv({ baseEnv: process.env, overrides: config.env }). That helper removes only the dangerous-key policy (loader/interpreter pivots), so credentials pass through. The Gateway loads ~/.openclaw/.env and config env sources into process.env.
  • Contract: the sibling path for the same launch config, bundle MCP stdio (OpenClawStdioClientTransport), has started servers from the MCP SDK getDefaultEnvironment() allowlist (HOME, LOGNAME, PATH, SHELL, TERM, USER; the standard system variables on Windows) plus configured env since 5f7b44045dc ("fix(mcp): tear down stdio process trees"), matching the SDK's own StdioClientTransport default. The LSP spawner never adopted that base.

Why This Change Was Made

spawnLspServerProcess() now passes a base built from getDefaultEnvironment() plus a short allowlist copied from the Gateway env: LANG, LANGUAGE, LC_*, TZ, TMPDIR/TMP/TEMP, the XDG_* base directories, GOROOT, GOMODCACHE, GOBIN, JAVA_HOME, RUSTUP_HOME, RUSTUP_TOOLCHAIN (matched case-insensitively on Windows). These are the locations language servers commonly read; none is a credential. They are inherited rather than left to the bundle env because bundle authors, not operators, write that env, and the exec override policy already refuses the XDG_* and rustup names there. The base still goes through sanitizeHostExecEnv(), so the dangerous-key and override policies are unchanged: SHELL is still dropped, and GOPATH and CARGO_HOME stay dropped because the host exec env policy blocks them on inheritance (they were not inherited before this change either). Keeping those two would mean bypassing that shared policy for LSP only, which this PR does not do.

The base env, the withheld-name detection, and the hint text live in src/agents/agent-bundle-lsp-env.ts and are shared by the spawn-time warning and the doctor note (src/commands/doctor-bundle-lsp-env.ts, contribution doctor:bundle-lsp-env). Withheld names are classified with the existing inspectHostExecEnvOverrides() policy check, so the hint tells the truth about whether the server's env can supply each name. The doctor note loads bundle LSP config for every configured agent workspace, the same per-workspace resolution the runtime uses, and evaluates every workspace's launch config for a server name before merging the names, so a workspace that supplies a variable in its env does not hide that another workspace's server of the same name lacks it.

Scope: bundle LSP servers only. Bundle MCP stdio servers already use the allowlist and are unchanged. Independent of the open Signal daemon (#179198) and hook token (#179199) PRs; no shared code. With #179199, the hook token would also be withheld here, but this change no longer needs it for LSP.

Real behavior proof

Behavior fixed: environment of a bundle-declared LSP server started by the bundle LSP runtime, and the operator-facing warning and doctor note for variables it no longer gets.

Environment: Linux, Node 24.19, this branch and its base 7e3fdabe52a. A script set four synthetic canaries in process.env (OPENCLAW_GATEWAY_TOKEN, OPENCLAW_HOOK_TOKEN, OP_CONNECT_TOKEN, OPENAI_API_KEY), wrote a temporary Claude-format bundle whose .lsp.json declares a small real stdio LSP server (Content-Length framed JSON-RPC; answers initialize and textDocument/hover with which canary names it sees) with env: { LSP_LOG_LEVEL: "verbose" }, ran createBundleLspToolRuntime() with the built process owner, executed the resulting lsp_hover_envprobe agent tool, read the server's /proc/<pid>/environ, then disposed the runtime.

Before (base):

tools: lsp_hover_envprobe
lsp server: 51 env vars; canaries in /proc/<pid>/environ: OPENCLAW_GATEWAY_TOKEN, OPENCLAW_HOOK_TOKEN, OP_CONNECT_TOKEN, OPENAI_API_KEY
lsp_hover_envprobe tool reply: canaries seen by server: OPENCLAW_GATEWAY_TOKEN, OPENCLAW_HOOK_TOKEN, OP_CONNECT_TOKEN, OPENAI_API_KEY; configured LSP_LOG_LEVEL: verbose

After (this branch):

env names: HOME, LANG, LOGNAME, LSP_LOG_LEVEL, OPENCLAW_CLI, PATH, TERM, USER, XDG_RUNTIME_DIR
tools: lsp_hover_envprobe
lsp server: 9 env vars; canaries in /proc/<pid>/environ: none
lsp_hover_envprobe tool reply: canaries seen by server: none; configured LSP_LOG_LEVEL: verbose

The server initialized and answered its tool call in both runs, and the configured env value arrived in both.

Warning and doctor note: same real bundle and server, with HTTPS_PROXY (a URL carrying a fake user and password), NO_PROXY, SSL_CERT_FILE, VIRTUAL_ENV, GOFLAGS, GOPATH, GOMODCACHE, GOBIN, DOTNET_ROOT, OPENAI_API_KEY, and NPM_TOKEN set to synthetic values in the Gateway env. The runtime was created twice (two turns), the warnings the runtime logged were captured, and the doctor note was built through the real loadEnabledBundleLspConfig() for the same bundle.

Before (previous head a97b326aa37):

turn 1: lsp server env names: HOME, LANG, LOGNAME, LSP_LOG_LEVEL, OPENCLAW_CLI, PATH, TERM, USER, XDG_RUNTIME_DIR
turn 2: lsp server env names: HOME, LANG, LOGNAME, LSP_LOG_LEVEL, OPENCLAW_CLI, PATH, TERM, USER, XDG_RUNTIME_DIR
bundle-lsp warnings for "envprobe" across 2 runtime starts: 0

After (this head):

turn 1: lsp server env names: GOBIN, GOMODCACHE, HOME, LANG, LOGNAME, LSP_LOG_LEVEL, OPENCLAW_CLI, PATH, TERM, USER, XDG_RUNTIME_DIR
turn 2: lsp server env names: GOBIN, GOMODCACHE, HOME, LANG, LOGNAME, LSP_LOG_LEVEL, OPENCLAW_CLI, PATH, TERM, USER, XDG_RUNTIME_DIR
bundle-lsp warnings for "envprobe" across 2 runtime starts: 1
warning: [bundle-lsp] server "envprobe" starts without these Gateway environment variables. DOTNET_ROOT: add to the server's "env" in its bundle .lsp.json if it needs them. GOFLAGS, GOPATH, HTTPS_PROXY, NO_PROXY, SSL_CERT_FILE, VIRTUAL_ENV: refused by the host exec env policy, also in "env"; a server that needs them must set them itself (for example, a wrapper script as its "command"). See https://docs.openclaw.ai/plugins/bundles#lsp-server-environment
any canary value in warnings: false
doctor note:
[Bundle LSP environment]
Bundle LSP servers start from an allowlisted environment, not the full Gateway environment. These Gateway variables are set but not passed:
- "envprobe": DOTNET_ROOT: add to the server's "env" in its bundle .lsp.json if it needs them.
- "envprobe": GOFLAGS, GOPATH, HTTPS_PROXY, NO_PROXY, SSL_CERT_FILE, VIRTUAL_ENV: refused by the host exec env policy, also in "env"; a server that needs them must set them itself (for example, a wrapper script as its "command").
Docs: https://docs.openclaw.ai/plugins/bundles#lsp-server-environment
any canary value in doctor note: false

OPENAI_API_KEY and NPM_TOKEN appear in neither output, and no value appears anywhere.

Shipped openclaw doctor, two workspaces reusing a server name: built dist for the previous head c0258c621a6 and this head 846f7a99a1a, then ran node dist/index.js doctor --non-interactive under env -i with an isolated HOME, OPENCLAW_STATE_DIR, and OPENCLAW_CONFIG_PATH (no installed service, Gateway port pinned to an unused port). The config has two agents with separate workspaces. Each workspace holds an enabled workspace Claude bundle (.openclaw/extensions/kotlin-a, kotlin-b) whose .lsp.json declares server kotlin; workspace A's server sets ANDROID_HOME in its env, workspace B's does not. The doctor env had ANDROID_HOME and a runtime-generated OPENAI_API_KEY canary.

Before (c0258c621a6): the contribution ran and printed nothing, because the first workspace's kotlin config hid the second.

Doctor: Bundle LSP environment
Doctor: GitHub projects

After (846f7a99a1a):

Doctor: Bundle LSP environment
◇  Bundle LSP environment
│  Bundle LSP servers start from an allowlisted environment, not the full
│  Gateway environment. These Gateway variables are set but not passed:
│  - "kotlin": ANDROID_HOME: add to the server's "env" in its bundle
│    .lsp.json if it needs them.
│  Docs: https://docs.openclaw.ai/plugins/bundles#lsp-server-environment

The canary appears 0 times in either full doctor log, and no ANDROID_HOME value appears.

Performance: same host and workload, createBundleLspToolRuntime() start (spawn plus initialize) to ready, 1 warmup plus 7 measured starts per run, with HTTPS_PROXY, VIRTUAL_ENV, and DOTNET_ROOT set so the withheld-name check runs. Previous head vs this branch, four interleaved rounds: previous head medians 186.5 / 177.7 / 174.4 / 171.4 ms, this branch 181.3 / 170.4 / 183.6 / 166.9 ms; the final head after the last edit measured 181.5 / 167.7 / 177.3 / 180.2 ms. The ranges overlap and the winner flips between rounds, so there is no measurable difference. The first change (secret scrub) measured the same way against base 7e3fdabe52a: base 162.3 / 174.1 / 176.2 / 167.4 ms, scrub 179.5 / 173.8 / 163.3 / 164.7 ms. The change adds one pass over the parent environment and one check of about thirty names per server start.

Latest-stable upgrade run through the shipped Gateway and Doctor (added 2026-10-21, head 846f7a99a1a): fully isolated throwaway prefix, HOME, OPENCLAW_HOME, OPENCLAW_STATE_DIR, OPENCLAW_CONFIG_PATH, and XDG_RUNTIME_DIR (no user bus, no installed service), Gateway on an unused loopback port, Node 24.19. The model is a loopback OpenAI-compatible stub so turns complete without a real provider. Gateway env: runtime-generated fake OPENCLAW_GATEWAY_TOKEN, OPENAI_API_KEY, OPENCLAW_HOOK_TOKEN, plus CARGO_TARGET_DIR, HTTPS_PROXY, NO_PROXY. A Claude-format bundle envprobe-bundle declares one stdio LSP server envprobe that records the env var names it starts with (names only) and answers initialize.

  1. npm install -g --prefix $T/prefix openclaw@2026.10.5 (npm latest), openclaw plugins install --accept-capabilities ./envprobe-bundle, openclaw gateway run --port <port>, then openclaw agent --agent main -m "say hi" through the Gateway (reply probe ok).
OpenClaw 2026.10.5 (1b58cb9)
envprobe start: 37 env names
  credential/withheld-candidate names seen: OPENCLAW_GATEWAY_TOKEN, OPENAI_API_KEY, OPENCLAW_HOOK_TOKEN, CARGO_TARGET_DIR, HTTPS_PROXY, NO_PROXY
stable `openclaw doctor --non-interactive`: no "Bundle LSP environment" section
  1. Stopped the stable Gateway and upgraded the same state to this branch's build (dist built in the PR worktree, OpenClaw 2026.10.5 (846f7a9)). Ran Doctor the way openclaw update does (OPENCLAW_UPDATE_IN_PROGRESS=1 openclaw doctor --fix --non-interactive --no-workspace-suggestions); it migrated the agent database (v25 -> v31) and printed:
◇  Bundle LSP environment
│  Bundle LSP servers start from an allowlisted environment, not the full
│  Gateway environment. These Gateway variables are set but not passed:
│  - "envprobe": CARGO_TARGET_DIR: add to the server's "env" in its
│    bundle .lsp.json if it needs them.
│  - "envprobe": HTTPS_PROXY, NO_PROXY: refused by the host exec env
│    policy, also in "env"; a server that needs them must set them itself
│    (for example, a wrapper script as its "command").
│  Docs: https://docs.openclaw.ai/plugins/bundles#lsp-server-environment

Credential names appear nowhere in Doctor output, and none of the three fake credential values appears in any log from the run.

  1. Bundle settings preserved across the upgrade:
plugins before: {"entries": {"envprobe-bundle": {"enabled": true}}}
plugins after:  {"entries": {"envprobe-bundle": {"enabled": true}}}
config top-level keys changed by upgrade: []
installed .lsp.json identical to source bundle
openclaw plugins inspect envprobe-bundle (PR build): Status: enabled, Format: bundle, Bundle format: claude, Bundle capabilities: lspServers, LSP servers: envprobe
  1. Started the PR Gateway on the same state and ran a turn (reply probe ok):
envprobe start: 12 env names
  credential/withheld-candidate names seen: (none)
  all names: HOME, LANG, LOGNAME, OPENCLAW_CLI, PATH, USER, XDG_CACHE_HOME, XDG_CONFIG_HOME, XDG_DATA_DIRS, XDG_DATA_HOME, XDG_RUNTIME_DIR, XDG_STATE_HOME
gateway log: [bundle-lsp] server "envprobe" starts without these Gateway environment variables. CARGO_TARGET_DIR: add to the server's "env" in its bundle .lsp.json if it needs them. HTTPS_PROXY, NO_PROXY: refused by the host exec env policy, also in "env"; a server that needs them must set them itself (for example, a wrapper script as its "command"). See https://docs.openclaw.ai/plugins/bundles#lsp-server-environment
  1. Documented recovery: in the bundle's .lsp.json, added "env": { "CARGO_TARGET_DIR": "<path>" } and pointed command at a wrapper script that exports HTTPS_PROXY and NO_PROXY and then runs the server; re-applied with openclaw plugins install --force --accept-capabilities ./envprobe-bundle (Applied in Gateway generation 3., no Gateway restart). Next turn (reply probe ok):
envprobe start: 17 env names
  credential/withheld-candidate names seen: CARGO_TARGET_DIR, HTTPS_PROXY, NO_PROXY
  OPENCLAW_* names seen: OPENCLAW_CLI
gateway log: [bundle-lsp] server "envprobe" starts without these Gateway environment variables. HTTPS_PROXY, NO_PROXY: refused by the host exec env policy, ...
openclaw doctor --non-interactive: - "envprobe": HTTPS_PROXY, NO_PROXY: refused by the host exec env policy, ... (CARGO_TARGET_DIR no longer listed)
plugins after recovery: {"entries": {"envprobe-bundle": {"enabled": true}}}

The granted CARGO_TARGET_DIR reaches the server through env; the refused names reach it only through the wrapper, which the Gateway warning and Doctor still mention because they cannot see what a wrapper sets. The fake credentials stay withheld after recovery. Throwaway Gateway and stub stopped afterwards.

Notes from the run: the PR build's openclaw doctor --non-interactive without --fix stopped at the existing agent database migration gate (stable writes schema v25, this base needs v31), which is the normal stable-to-main upgrade gate and why step 2 uses the update path's --fix. Hand-editing the installed copy of .lsp.json under the state dir was picked up by Doctor (a fresh process) but not by the already-running Gateway until the bundle was re-applied with plugins install --force; this branch does not touch bundle config loading or caching.

What was not tested

  • Real third-party language servers (typescript-language-server, gopls, rust-analyzer, jdtls) under the reduced environment; none was installed on the proof host. The proof uses a minimal real stdio LSP server through the real runtime.
  • Windows and macOS hosts. Windows case-insensitive matching is implemented but only exercised by the existing mocked Windows spawn tests.
  • A live Gateway agent turn calling an lsp_* tool: the upgrade run drives real Gateway turns that start the server, but the stub model makes no tool call. openclaw doctor reading an installed Gateway service environment: all runs above use isolated state with no installed service (the service env read is covered by unit tests). The upgrade run uses this branch's worktree dist, not an npm-packed tarball of it. The doctor:bundle-lsp-env contribution runner (workspace list plus doctor env, like doctor:web-fetch-proxy) has no dedicated test; doctor-health-contributions.test.ts is at its line-cap ratchet.
  • Language servers that depend on proxy or CA bundle variables or GRADLE_USER_HOME: these were inherited before and are now withheld, and the host exec env policy also refuses them in a server's env. The warning, doctor note, and docs name them and the wrapper-script route; this is the compatibility tradeoff.

Verification

  • src/agents/agent-bundle-lsp-runtime.windows-spawn.test.ts: tests for Gateway secrets withheld while PATH, HOME, LC_ALL, RUSTUP_HOME are kept; configured env still applied; GOMODCACHE/GOBIN kept while GOPATH/CARGO_HOME stay dropped; one warning per server across two starts that names withheld variables split by whether env can supply them, never values, never NPM_TOKEN; and a name the server's env supplies is not listed. On the previous head the three new tests fail; with this head all 8 pass. Added on 321e3376f43: GRADLE_USER_HOME survives the host exec env policy alone but is withheld from the LSP child and reported as refused (fails when GRADLE_USER_HOME is added to the LSP allowlist; 9 pass on this head).

  • src/commands/doctor-bundle-lsp-env.test.ts (8 tests): names per configured server and category, no values or secret names; quiet without runnable bundle LSP servers, without any listed variable set, and for remote Gateways; omits names a server's env supplies; evaluates each workspace's config when two workspaces reuse a server name (fails on c0258c621a6: no note; passes on 846f7a99a1a); includes the installed Gateway service environment; does not read the service for a non-default install identity.

  • agent-bundle-lsp-runtime.test.ts, doctor-health-contributions.test.ts, doctor-health.update-scope.test.ts, host-env-security.test.ts still pass (138 tests across the 6 files).

  • pnpm check:changed on 846f7a99a1a: all lanes pass (typecheck core and core tests, lint, format, deprecated API, mock export, line-cap ratchets) except two that fail on things this branch does not touch: the max-lines suppression ratchet (three ui/src files) and the advisory core test shard root budget (shards agents-root, agents-tools, gateway-root, infra, plugins-platform already over 720 roots on the base; the new test file is outside those shards).

  • pnpm docs:check-links:anchors: no findings for docs/plugins/bundles.md (the new #lsp-server-environment anchor resolves); the remaining findings are in unrelated pages.

  • CI run 39616436281 on head f33802d5bf6: the one failed job, checks-node-changed-compact-large-15 (job), and the openclaw/ci-gate red that follows from it are inherited from main, not caused by this branch. pr-failure-report printed "Classification unavailable", so the comparison was done by hand. All 6 failures are in src/commands/cleanup-live-state.test.ts (registered reset/uninstall workspace guard > handles workspace warning ..., lines 185 and 192). The error is Cannot safely remove OpenClaw state because workspace configuration could not be resolved: agents.defaults: Unrecognized key: "heartbeat". The newest completed scheduled main CI run, 39608923095 (bedbf6761e0), fails the same 6 tests with the same message in checks-node-compact-small-9 (job). The fixture at cleanup-live-state.test.ts:164 still sets agents.defaults.heartbeat, which became an unrecognized key on main after feat(automations): migrate heartbeat jobs through Doctor #179387. This branch does not touch that test, the cleanup command, or the config schema. The security review on this head passed.

  • CI run 39622230808 on head c0258c621a6: the failed job checks-node-changed-compact-large-13 is the same inherited src/commands/cleanup-live-state.test.ts failure described above (registered reset/uninstall workspace guard > handles workspace warning ...).

  • CI run 39670707818 on head 846f7a99a1a: the failed job checks-node-changed-compact-large-6 (job) and the openclaw/ci-gate red that follows from it are inherited from main, not caused by this branch. The one failure is src/cli/gateway-status-route-cold-imports.test.ts > keeps plain-config status off the full config runtime (expected true to be false at line 93). Scheduled main CI runs 39662150265 (a24b17a9227, checks-node-compact-small-34, job) and 39654415683 (2a597857a05) fail the same test with the same assertion. Locally the test passes on this branch's base and on this head, and fails on plain main at a83e3190ce6 (the main commit CI merged this head into) and at 548a331adb1. git bisect between this branch's base and a83e3190ce6 names 37e2f26636e (fix(status): reconcile degraded secret diagnostics #126786) as the first failing commit. This branch does not touch the gateway status route, src/config/io.runtime.ts, or that test.

Bundle LSP servers were spawned from the full Gateway process.env (minus
the dangerous-key policy), so provider API keys, Gateway and hook tokens
and secret-manager credentials reached every plugin-declared language
server. Bundle MCP stdio servers, which use the same launch config, already
start from the MCP SDK default environment.

Start LSP servers from the same MCP defaults plus locale, temp, XDG and
toolchain location variables, and keep applying the server's configured
env through the existing exec override policy.
@VACInc VACInc self-assigned this Oct 21, 2026
@clawsweeper

clawsweeper Bot commented Oct 21, 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: S labels Oct 21, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 21, 2026
@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR restricts bundled LSP child environments and adds warnings, Doctor diagnostics, and recovery documentation.

Example: A bundle starts an LSP server while OPENAI_API_KEY=provider-key-canary and LSP_LOG_LEVEL=verbose is configured.

  • Before: The child receives the Gateway API key and the configured log level.
  • After: The child receives LSP_LOG_LEVEL=verbose without inheriting OPENAI_API_KEY.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, correct security repair with production and upgrade proof, resolved prior findings, and a documented compatibility tradeoff.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Linux production-runtime output shows a real stdio LSP server initializing and answering hover while synthetic Gateway credentials are absent from its actual environment and configured env still arrives. The shipped Gateway and Doctor upgrade from v2026.10.5 preserves bundle settings and demonstrates recovery for intentionally withheld variables. The latest commit changes documentation and regression coverage without changing the proven production path; third-party server and native Windows/macOS coverage remain declared limits.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Bundle-declared language servers receive unrelated Gateway credentials and pass them to their descendants.
Reason: Reducing unnecessary credential propagation has clear value, and the maintainer-authored direction explicitly accepts the compatibility impact with warnings, Doctor guidance, and demonstrated recovery.

Merge readiness

✅ Ready for maintainer review

This PR fixes credential inheritance that remains on main; the previous findings are resolved, and no blocking defect remains in the reviewed diff.

Priority: P2
Reviewed head: 321e3376f43540da92f76990d1fee6e43e8bc536

Before merge

None.

Findings

None.

Agent review details

How this fits together

Enabled bundle metadata supplies LSP launch configurations; the agent runtime starts owned stdio processes, initializes language servers, and exposes their capabilities as agent tools.

flowchart TD
A[Enabled bundle configuration] --> B[LSP runtime]
B --> C[Shared LSP environment policy]
D[Gateway environment] --> C
C --> E[Owned stdio process]
E --> F[LSP agent tools]
C --> G[Warnings and Doctor diagnostics]
Loading

Technical review

Best possible solution:

Land the allowlisted environment with the shared diagnostics and documented recovery path.

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

Current-main source establishes the inheritance path, and the supplied before/after process-environment and LSP-tool output demonstrate it with synthetic credentials; no target code was executed during this review.

Is this the best way to solve the issue?

The fix changes the spawning owner, preserves the shared host policy and configured env, and shares diagnostics between runtime and Doctor; the added modules serve the security change and its accepted compatibility recovery.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1350f617d48d.

Provenance checked

  • LSP inherited environment changes intended behavior with a stated reason (unknown: The process-owner extraction in 60a3b16 preserved existing launch behavior for deterministic tests; it does not establish why full inheritance originally existed. Scoped git log -S and git log --follow encountered unavailable older blobs.)
  • Windows invocation and owned-process cleanup keeps the original intent (fix(lsp): resolve Windows .cmd shims in spawnLspServerProcess #75343: Resolve Windows npm shims while retaining shell fallback for unresolved wrappers; later lifecycle work preserves exact environments and owned cleanup.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main still inherits the Gateway environment: The fetched main process owner passes process.env to sanitizeHostExecEnv; the sanitizer removes dangerous execution variables but does not generally remove provider credentials. (src/agents/agent-bundle-lsp-process.ts:15, 1350f617d48d)
  • Fix reaches the final process boundary: The LSP process owner resolves the allowlisted environment and passes it to createOwnedStdioProcess with exactEnv=true; the child adapter preserves that environment rather than merging the Gateway environment back in. (src/agents/agent-bundle-lsp-process.ts:37, 321e3376f435)
  • Production and upgrade proof: The complete PR body records real stdio initialization and hover output with four synthetic credentials absent from the child, shipped Doctor output, and a v2026.10.5-to-branch Gateway upgrade preserving bundle settings and demonstrating configured-env and wrapper recovery. (846f7a99a1a9)
  • Previous findings resolved: Doctor retains every workspace's launch environment before merging withheld names, and the current body correctly categorizes GRADLE_USER_HOME as newly withheld; the latest commit also documents its refused-override status. (src/commands/doctor-bundle-lsp-env.ts:25, 321e3376f435)
  • Compatibility tradeoff explicitly accepted: The maintainer-authored PR explicitly accepts withholding proxy, CA, and other non-allowlisted variables, documents affected setups, and demonstrates recovery; guidance is published under https://docs.openclaw.ai/plugins/bundles#lsp-server-environment. (docs/plugins/bundles.md:135, 321e3376f435)
  • Exact-head checks: The paginated check-runs response contains no failed or pending checks, and openclaw/ci-gate, dependency review, and security-sensitive review report success for the reviewed head; mergeability remains unknown. (321e3376f435)

Likely related people:

  • Peter Steinberger: Raw commit bcef3b3 adds src/agents/agent-bundle-lsp-process.ts:41 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: bcef3b3526dd; files: src/agents/agent-bundle-lsp-process.ts)
  • Vincent Koc: Raw commit 30e3f86 adds src/flows/doctor-health-contribution-runners.gateway.ts:22 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 30e3f865fde0; files: src/flows/doctor-health-contribution-runners.gateway.ts)

PR surface

Source +316, Tests +264, Docs +52. Total +632 across 9 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 6 322 6 +316
Tests 2 267 3 +264
Docs 1 52 0 +52
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 641 9 +632

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The repair limits unnecessary credential exposure in the optional bundle LSP workflow without evidence of an active exploit or core outage.
  • merge-risk: 🚨 compatibility: Existing language servers lose arbitrary inherited variables, including proxies, CA settings, and custom Gradle homes; the maintainer-authored PR explicitly accepts this tradeoff and supplies diagnostics and recovery proof.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-21T11:36:20.654Z sha a97b326 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-21T19:52:37.300Z sha c0258c6 :: needs changes before merge. :: [P2] Preserve workspace-specific LSP configurations in Doctor
  • reviewed 2026-10-21T21:22:45.534Z sha 846f7a9 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-21T23:34:18.422Z sha 846f7a9 :: needs changes before merge. :: [P3] Correct the upgrade note for GRADLE_USER_HOME

Reviewed October 21, 2026, 9:59 PM ET / October 22, 2026, 01:59 UTC (Revision 5).

Keep GOMODCACHE and GOBIN in the bundle LSP base env. GOPATH and
CARGO_HOME stay dropped by the host exec env policy.

Log one warning per server when commonly needed, non-secret Gateway
variables (proxy, CA bundle, Python, Node, Go, Rust, JVM, .NET, Android)
are set but not passed, split into names the server's env can supply and
names the policy refuses there too. Add a matching openclaw doctor note for
configured bundle LSP servers, reading the doctor and installed Gateway
service environments. Both print names only and skip secret-looking names.

Document the LSP server environment and how to pass variables.
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: L and removed size: S labels Oct 21, 2026
@VACInc

VACInc commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Secret scanners flag scheme://user:pass@host literals. Split the synthetic proxy URL so the runtime value and assertions stay identical.
@VACInc

VACInc commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@VACInc

VACInc commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@VACInc

VACInc commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 21, 2026
@VACInc

VACInc commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 21, 2026
@VACInc

VACInc commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 21, 2026
The host exec env policy lets a child inherit GRADLE_USER_HOME, so bundle
LSP servers got it before the allowlist; it is now withheld and the policy
refuses it in a server's env. Name it in the docs and pin the behavior.
@VACInc

VACInc commented Oct 22, 2026

Copy link
Copy Markdown
Member Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 22, 2026
@VACInc
VACInc merged commit 9bbd4fa into openclaw:main Oct 22, 2026
141 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 22, 2026
* fix(lsp): bundle LSP servers inherit Gateway secrets

Bundle LSP servers were spawned from the full Gateway process.env (minus
the dangerous-key policy), so provider API keys, Gateway and hook tokens
and secret-manager credentials reached every plugin-declared language
server. Bundle MCP stdio servers, which use the same launch config, already
start from the MCP SDK default environment.

Start LSP servers from the same MCP defaults plus locale, temp, XDG and
toolchain location variables, and keep applying the server's configured
env through the existing exec override policy.

* fix(lsp): name Gateway env vars bundle LSP servers no longer get

Keep GOMODCACHE and GOBIN in the bundle LSP base env. GOPATH and
CARGO_HOME stay dropped by the host exec env policy.

Log one warning per server when commonly needed, non-secret Gateway
variables (proxy, CA bundle, Python, Node, Go, Rust, JVM, .NET, Android)
are set but not passed, split into names the server's env can supply and
names the policy refuses there too. Add a matching openclaw doctor note for
configured bundle LSP servers, reading the doctor and installed Gateway
service environments. Both print names only and skip secret-looking names.

Document the LSP server environment and how to pass variables.

* test(lsp): build credentialed proxy URL fixtures at runtime

Secret scanners flag scheme://user:pass@host literals. Split the synthetic proxy URL so the runtime value and assertions stay identical.

* fix(doctor): evaluate every workspace's bundle LSP config for withheld env names

* docs(lsp): list GRADLE_USER_HOME as newly withheld and refused in env

The host exec env policy lets a child inherit GRADLE_USER_HOME, so bundle
LSP servers got it before the allowlist; it is now withheld and the policy
refuses it in a server's env. Name it in the docs and pin the behavior.

---------

Co-authored-by: VACInc <3279061+VACInc@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

⌂ 换网址