Skip to content

[SECURITY] Stop logging secret-bearing process arguments at MCP startup #825

Closed

Description

@jeffreyaven

Constituent of #769. Reviewed main at 1de4135 on 2026-10-08. Specification only; no implementation included.

CWEs: CWE-532, CWE-200.

Finding

MCP startup writes full os.Args to stderr. A current-build launch with --http.proxy.password=FAKE-PROBE-PASSWORD printed that exact value without HTTP debug logging. MCP hosts commonly retain stderr.

Required policy

Preserve useful startup configuration. Mask credential values, not every configuration blob, path, hostname or free-text argument. Use the fixed literal [REDACTED] in a diagnostic copy only.

The intended --auth contract is a provider configuration struct containing metadata and references to environment variables holding credentials. Reference names are not secret values. Keep those names and never resolve them for logging. The current pinned any-sdk DTO also accepts inline credentials; this is an existing contract mismatch, not a reason to hide the normal reference-only struct. Changing or rejecting those auth inputs is separate work from #825.

What remains visible

  • --auth: provider names, type, environment-variable reference names, file references and other non-secret metadata. Examples: credentialsenvvar, credentialsfilepathenvvar, api_key_var, api_secret_var, password_var, client_secret_env_var, private_key_env_var, and passphrase_env_var remain visible. No file or environment contents are read for diagnostics.
  • --registry: ordinary URL and registry settings. A registry URL is not classified as a secret. Apply the narrow URL rule below only if credentials are explicitly embedded in it.
  • --var: preserve Jsonnet variable names and values, including repeated/comma-separated arguments. The implementation feeds these into jsonnet.VM.ExtVar; [SECURITY] Stop logging secret-bearing process arguments at MCP startup #825 must not add secret-name guessing, value scanning or blanket redaction to this flag.
  • Paths, hostnames, proxy username, provider names, non-secret config fields, and numeric/boolean/enum settings remain visible. This includes --env.file, --approot, --http.proxy.user, --http.proxy.host, and the non-secret contents of --preview, --dbInternal, --namespaces, --store.txn, --gc, --acid, --session, and --pgsrv.sundry.

Exact protected values

Argument Mask Preserve
--http.proxy.password Entire password value Flag name and separate proxy user/host/port/scheme
--auth If supplied despite the intended reference-only contract: inline api_key, api_secret, password, client_secret, private_key, passphrase; apply the same rules inside successor. Mask sqlDataSource.dsn. Within custom OAuth values, mask only entries matching the credential-key list below Provider structure, references, usernames/IDs and other fields; never mask a reference merely because its name includes secret or password
--sqlBackend Inline dsn field as a unit, since it can carry a URL or keyword connection string with credentials dsnEnvVar, engine/dialect, schema, retry and other settings
--mcp.config Inline backend.dsn as a unit. Within server.transport_cfg, mask only entries matching the credential-key list below Transport, mode, limits, audit configuration, server.auth_token_env_var, TLS file paths and other non-secret fields
--otel.config Each value in exporter.headers, retaining header names; custom header names can carry ingestion tokens. Apply URL rule to exporter.endpoint Endpoint without embedded credentials, timeout and batch settings
--pgsrv.tls Inline keyContents Certificate contents, CA configuration, certificate/key paths and other settings

The MCP connection field is backend.dsn, the JSON/YAML tag on BackendConfig.ConnectionString; it is not backend.connection_string.

Credential-key list for the two custom maps above: password, passwd, pwd, secret, client_secret, api_key, api_secret, access_token, refresh_token, id_token, token, authorization, proxy_authorization, private_key, passphrase. Match complete keys case-insensitively, ignoring _ and -; do not substring-match. This does not match reference keys such as client_secret_env_var. Apply to nested maps/lists inside those two containers only, not globally to unrelated configuration or Jsonnet variables.

URL rule: retain normal URL text. If URL userinfo includes a password, mask that password and retain username/host/path. For query parameters, mask values whose decoded keys match the credential-key list above, or signature, sig, x-amz-signature, x-amz-security-token, x-goog-signature; preserve other parameters. Apply to schema-defined URL fields in auth, registry, preview, MCP and OTLP configuration, not arbitrary strings or --var. This is explicit field-based protection, not a promise to detect secrets hidden under arbitrary names.

Parsing and failure handling

  • Cover --flag=value, --flag value, repeats, aliases and values beginning with -. Do not mutate input args, parsed flags, runtime structs, files or environment.
  • Respect each flag's supported JSON/YAML syntax and the runtime's case/duplicate-key interpretation. Traverse a diagnostic copy; do not invoke credential getters or create connections.
  • If a configuration that requires sanitisation cannot be safely parsed, mask that argument value only. If only a URL subfield cannot be safely sanitised, mask that subfield. Never fall back to logging the protected raw input or parser errors containing it.
  • Keep normal registered arguments visible. Do not introduce a blanket numeric/boolean/enum allowlist or blanket masking of future string flags. Explicitly classify new credential-bearing fields when added. Omit unknown options and arbitrary positional payloads from this startup diagnostic.

Compatibility and scope

Keep version, platform, PID and effective transport diagnostics. Sanitation changes only stderr text. Stdout remains MCP protocol traffic. Authentication, credential reload, query execution, configuration precedence and long-lived/idle stdio sessions must behave identically. No timeouts or concurrency changes belong in this issue; #828 is separate.

Enforcing an environment-reference-only auth contract would be a separate compatibility change. #825 defensively hides currently accepted inline secrets without introducing, encouraging or removing inline auth support.

#606 covers CI exposure, #359 request-header diagnostics, #816 AUTH source errors/state, and #824 malformed MCP configuration. This issue does not claim to sanitise all application logs or arbitrary secret content placed in Jsonnet variables.

Validation and acceptance

  • Positive disclosure tests: normal env-reference-only auth, registry URLs, Jsonnet names/values, paths, proxy username and non-secret config fields remain in the diagnostic. Reference values named MY_CLIENT_SECRET or PASSWORD_ENV remain visible.
  • Negative disclosure tests: distinct fake markers in each protected value above are absent; sibling metadata remains. Cover nested successor auth, custom OAuth/transport maps, DSNs, custom OTLP header names, inline TLS key material and embedded URL credentials.
  • Exercise both flag syntaxes, repeats, aliases, empty/dash-prefixed values, JSON/YAML where supported, malformed input and case/duplicate-key variants. Confirm no raw-value fallback or mutation.
  • Capture built-binary stderr for normal and failed MCP startup, including bundle launch forms, and check this diagnostic. Existing unrelated error leaks should be recorded separately, not silently widen this issue.
  • Add appropriate black-box stdio coverage showing successful initialise/tool calls and unchanged configuration/credential use. Run repository-required build, unit, lint and relevant robot checks; report any unavailable checks explicitly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions