Skip to content

Show env values in the server.json launch preview and confirm runtime-control vars - #2945

Merged
cliffhall merged 4 commits into
v2/mainfrom
v2/fix/ghsa-pp85-truthful-launch-preview-env
Nov 11, 2026
Merged

cliffhall merged 4 commits into
v2/mainfrom
v2/fix/ghsa-pp85-truthful-launch-preview-env

Conversation

@cliffhall

@cliffhall cliffhall commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Closes #2949

The fix was developed and reviewed in the advisory's private fork. These are the reviewed commits, pushed here unchanged. Tracking issue: #2949.

Fix for GHSA-pp85-586h-2m95 (v2 only, affects <= 2.14.0).

Problem

Importing a registry server.json copies each declared environment variable's default/value into the saved config's env, and the stdio spawn passes it to the launched process. The import panel's "Command to Run" preview listed only the env var names, but it told the user the preview "is exactly what will be saved and run". Some variables change what an unchanged-looking command line actually runs, or where it downloads the package from.

Fix

  1. The preview is truthful. It shows NAME=value (value shell-quoted, the same quoting the command line uses) for every variable the launch sets. It is built from the same buildServerConfigForSelection output that submit persists, so it cannot drift from what is saved. A variable declared isSecret is masked (********) and badged Secret only when its value was entered by the user. A value the document itself supplies is not secret (it is in the pasted server.json), so it is always shown in clear. That decision compares against the document value in selectedOption.baseConfig.env, the same map the saved config is built from, so a name declared twice cannot mask a document-supplied value.
  2. Runtime-control variables are flagged. A new pure classifier, isRuntimeControlEnvVar (core/mcp/import/runtimeControlEnv.ts, exported from the import barrel), matches case-insensitively on PATH and the prefixes NODE_, NPM_CONFIG_, UV_, PIP_, PYTHON, DOCKER_, LD_, DYLD_, DOTNET_, NUGET_, CORECLR_, COMPLUS_ and OPENSSL_. It exempts a short allowlist of names that only change output (NODE_ENV, NODE_NO_WARNINGS, PYTHONUNBUFFERED, PYTHONIOENCODING, PYTHONUTF8, PYTHONDONTWRITEBYTECODE), and flags anything else in those families by default. DOTNET_/NUGET_/CORECLR_/COMPLUS_ are included because dnx is the fourth launch runtime (the CoreCLR profiler variables load a native library, the same class as LD_PRELOAD). OPENSSL_ is included because an OpenSSL config can load an engine or provider library into Node or Python. Flagged rows get a Runtime control badge and a warning that explains why. A flagged variable is never masked, even when it is declared isSecret. Otherwise a document could hide the exact value the preview exists to show.
  3. Confirm, don't block. When the launch sets any flagged variable, Add Server stays disabled until the user ticks a confirmation checkbox in the warning.
    • The confirmation is stored as a signature of the flagged names and values. Editing a flagged value, or switching to a package that sets different flagged values, withdraws it automatically, with no effect needed. submit re-checks the signature against the config it is about to save.
    • The user can clear a flagged value in the form instead. That removes it from the launch, and the need to confirm goes with it.
    • Why confirm rather than refuse or drop: a legitimate server can genuinely need one of these (a private npm/PyPI mirror, PYTHONPATH, a remote DOCKER_HOST). Refusing would make those servers impossible to import. Silently dropping the value would save a misconfigured server whose preview no longer matches what the author intended. Confirmation keeps the "exactly what will run" promise honest. Every value is shown, the risky ones are explained, and nothing is saved until the user has affirmatively accepted those specific values.
  4. isSecret form fields use PasswordInput when the document supplies no value for them (decided from the declaration, so the field does not switch type while typing). A flagged variable stays a plain TextInput even when declared secret, for the same reason as in 2. The password field has no clear button because its right section holds the visibility toggle.

Tests

  • clients/web/src/test/core/mcp/import/runtimeControlEnv.test.ts: flagged, case-insensitive, and not-flagged names, including PATHNAME/MY_PATH/NODE the allowlist, and the CORECLR_/COMPlus_/OPENSSL_ families.
  • useServerJsonImport.test.tsx: describeLaunch produces NAME=value, masks secrets, and never masks flagged vars. runtimeControlSignature changes only with flagged values. For the hook, Add is disabled until confirmed, editing a flagged value withdraws the confirmation (a non-flagged edit does not), clearing the flagged values removes the need to confirm, submit refuses unconfirmed values and saves confirmed ones verbatim, and re-opening the modal resets the confirmation, document-supplied secret values show in clear while user-entered ones are masked, and a duplicate-declared name follows the saved value.
  • ImportServerJsonPanel.test.tsx: env rows, the Secret badge, Runtime control badges, the role="group" env list, the warning text and checkbox wiring, and the password field.
  • Storybook: updated existing stories to the new env shape, and added RuntimeControlEnv and RuntimeControlEnvAcknowledged. The badge and alert use the theme's AA-contrast variants (Badge status, Alert warning), so the stories pass the a11y check.

Gate

npm run format then npm run local:gate: green (exit 0). (run locally in the fork; public CI runs here)

Screenshots

Captured from the dev server with a server.json declaring npm_config_registry, NODE_OPTIONS (marked isSecret), API_KEY (isSecret, document default, so shown in clear), a user-typed TOKEN (masked) and REGION.

import-preview-runtime-control-unconfirmed

import-preview-runtime-control-unconfirmed

import-preview-add-disabled-until-confirmed

import-preview-add-disabled-until-confirmed

import-preview-runtime-control-confirmed

import-preview-runtime-control-confirmed

🤖 Generated with Claude Code

cliffhall and others added 3 commits November 11, 2026 12:51
…-control vars

The server.json import copies each declared environment variable's
default/value into the saved config's env, and the stdio transport passes
it to the spawned process, but the "Command to Run" preview listed env var
names only while stating it is exactly what will be saved and run. Several
variables change what an unchanged command line executes or where it
fetches the package from (NODE_OPTIONS, npm_config_*, UV_*, PIP_*,
PYTHON*, DOCKER_*, LD_*, DYLD_*, DOTNET_*, NUGET_*, PATH).

- The preview now shows NAME=value (shell-quoted) for every variable the
  launch sets. A declared isSecret variable is masked and badged Secret.
- A new pure classifier, isRuntimeControlEnvVar (core/mcp/import), flags
  runtime-control variables case-insensitively, with a short allowlist of
  output-only names (NODE_ENV, PYTHONUNBUFFERED, ...). Flagged variables
  are badged in the preview, are never masked even when declared secret,
  and get a warning that explains why.
- Add stays disabled until the user confirms the flagged values. The
  confirmation is recorded against the flagged names and values, so
  editing one withdraws it; submit re-checks it against the config being
  saved. Values are not refused or dropped, since a legitimate server can
  need one (a registry mirror, PYTHONPATH, a remote docker host); clearing
  a flagged value removes it and the need to confirm.
- isSecret fields in the form render as a PasswordInput.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
…_/OPENSSL_

- Show a declared secret's document-supplied value in clear in the
  preview and form; mask only values the user entered (those differing
  from the declared default/value). A document could otherwise mark any
  variable isSecret to hide its own value, and a variable the classifier
  misses would then slip past the preview unseen. The form uses a
  PasswordInput only for a secret the document supplies no value for, so
  the field never swaps input types mid-typing.
- Flag CORECLR_* (profiler variables load a native library into the .NET
  runtime dnx starts), COMPlus_* (the legacy spelling of DOTNET_* knobs)
  and OPENSSL_* (an OpenSSL config can load an engine/provider library).
- Give the resolved-environment list role="group" so its label is
  announced.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
A name declared twice has one effective value in the saved env, but the
declared-secrets map took its value from whichever declaration came
last, so a duplicate isSecret entry with no default could mask the value
actually saved. Read each secret's document-supplied value from the
option's base env, the same map the saved config is built from, for both
the preview mask and the form's password field.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>

Copilot AI 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.

🟡 Changes recommended

Unresolved issues can expose secrets through duplicate fields, forward the host’s PATH without confirmation, and crash import previews for declarations named constructor or toString.

3 open issues
What changed in this PR

This PR addresses #2949 by showing environment values in the web client’s server.json launch preview and requiring confirmation for runtime-control variables, using a shared classifier in core/.

Changes:

  • Shows shell-quoted environment values, masking user-entered secrets but keeping runtime-control values visible.
  • Adds warning badges and confirmation tied to the flagged names and values.
  • Adds classifier, hook, and component tests plus Storybook examples.
File Description
core/​mcp/​import/​runtimeControlEnv.ts Adds case-insensitive runtime-control classification.
core/​mcp/​import/​index.ts Exports the classifier.
clients/​web/​src/​test/​core/​mcp/​import/​runtimeControlEnv.test.ts Tests flagged names, prefixes, and exemptions.
clients/​web/​src/​hooks/​useServerJsonImport.ts Builds value previews, derives masking, and gates submission on confirmation.
clients/​web/​src/​hooks/​useServerJsonImport.test.tsx Tests preview values, masking, confirmation, and submission.
clients/​web/​src/​components/​groups/​ServerImportJsonModal/​ServerImportJsonModal.tsx Connects confirmation state to the panel.
clients/​web/​src/​components/​groups/​ImportServerJsonPanel/​ImportServerJsonPanel.tsx Renders environment rows, warnings, confirmation, and password fields.
clients/​web/​src/​components/​groups/​ImportServerJsonPanel/​ImportServerJsonPanel.test.tsx Tests environment display and confirmation interactions.
clients/​web/​src/​components/​groups/​ImportServerJsonPanel/​ImportServerJsonPanel.stories.tsx Updates preview fixtures and adds runtime-control examples.

Review effort: Balanced

const masked = isMaskedSecret(name, value, secrets);
return {
name,
display: `${name}=${masked ? SECRET_MASK : quoteShellArg(value)}`,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 177fc08. buildServerConfigForSelection now reads the override map with Object.hasOwn, and the hook reads the override and document env maps through an own-property helper (ownValue), so a declaration named constructor/toString resolves to undefined rather than an inherited function. Regression test: "previews declarations named like Object.prototype members" (it failed with the arg.replace TypeError before the fix).

A name declared twice shares one value, so the form now hides every field
of a name any declaration marks secret, as the preview already did.

Env lookups keyed by a declared name read own properties only, so a
declaration named after an Object.prototype member no longer reads an
inherited function into the preview.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: cliffhall <[email protected]>
@cliffhall
cliffhall requested a balanced review from Copilot November 11, 2026 18:58
@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 1 (review 5863778608), answered in each thread:

  • Docker -e PATH forwarding after clearing a field: declined as out of scope. The forwarding predates this PR, and a cleared field forwards the host's own value, not one the document supplies.
  • Duplicate declarations exposing a typed secret: fixed in 177fc08 (secret fields are now decided by name).
  • Prototype-named declarations crashing the preview: fixed in 177fc08 (own-property reads).

No suppressed comments. Round 2 requested.

Copilot AI 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.

🟢 Approval recommended

There are no active review issues blocking approval.

1 open issue
2 resolved since last review

Review effort: Balanced

@cliffhall

Copy link
Copy Markdown
Member Author

Copilot round 2 (review 5864006510) was clean: no inline comments, the headline recommends approval, and there are no suppressed comments. The one item it still lists as open is the round-1 prototype-name thread, already fixed in 177fc08 and answered there. The review loop is closed on the clean-round exit (pr-flow 7c).

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

Labels

v2 Issues and PRs for v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GHSA-pp85-586h-2m95] - [v2] - server.json launch preview omits environment variable values

2 participants