Repository navigation
fix(upstream): never send an unresolved secret reference to an HTTP upstream - #1933
Merged
Merged
Conversation
…pstream
Release QA F9: a ${keyring:...} reference that could not be resolved in a
configured header was sent to the upstream verbatim
("Authorization: Bearer ${keyring:name}") and health stayed green. The core
client logged the failure and kept the raw value.
- A secret reference in the URL, headers or OAuth settings that cannot be
resolved when the client is built now makes the client refuse to connect,
sign in or refresh a token, before any HTTP request
(core.UnresolvedSecretError). The error names the reference and field, never
a value, and says how to add the secret and restart the server. It
classifies as MCPX_CONFIG_MISSING_SECRET and health shows "Missing secret"
with the set_secret action. References that resolve on the same server and
other servers are unaffected; local stdio fields keep the old behaviour.
- The resolution-failure log names the references only, not the field value.
- Storing a secret through REST or the Web UI restarted only servers that
referenced it in env or args; servers referencing it in the URL, headers or
OAuth settings are now restarted too.
Tests go through the runtime: a missing synthetic keyring key is refused with
nothing sent, an unrelated server connects, and after the key is added an
upstream restart (or storing the secret through the API) connects with the
resolved header and keeps a valid substitution; no secret value is logged.
Deploying mcpproxy-docs with
|
| Latest commit: |
dc86405
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://7e931d09.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-f9-unresolved-header-sec.mcpproxy-docs.pages.dev |
Review r1 on the F9 fix:
- Only an HTTP-family server sends its URL, headers and OAuth settings, so a
stale reference in those fields of a stdio server no longer stops it.
- The fix hint for ${env:NAME} says to restart mcpproxy: the env provider
reads mcpproxy's own environment, which a server restart cannot change.
- A field whose references resolve on a second look is reported with its
first reference, so health still reads "Missing secret".
- The resolution-failure log carries the provider's reason again (it names
references only), so "keyring unavailable" and "not found" stay apart.
- Storing or deleting a secret no longer restarts, and so re-enables, a
disabled server that references it.
- Tests check every logged field (arrays too), exercise both sign-in flows
with OAuth applicable, the hints, the reference scan and the disabled skip.
- Docs: ${env:} and other ${type:name} text in those fields is now refused
when it cannot be resolved; which restart picks a secret up.
…fig; poll the disabled-server check
Dumbris
enabled auto-merge (squash)
November 18, 2026 17:49
Dumbris
disabled auto-merge
November 18, 2026 19:08
Dumbris
enabled auto-merge (squash)
November 18, 2026 19:09
Contributor
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 44377578287 --repo smart-mcp-proxy/mcpproxy-go
|
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Release QA finding F9: when a configured upstream HTTP header contained a
${keyring:...}reference that could not be resolved, mcpproxy sent the raw text to the upstream (Authorization: Bearer ${keyring:name}), and the server's health stayed green.Cause.
core.NewClientWithOptionsexpands secret references withExpandStructSecretsCollectErrors. A field that fails keeps its original value. The failure was only logged, at ERROR, and that log line also carried the field's full value. Nothing stopped the connection.Changes
url, theheadersor theoauthsettings that cannot be resolved when the client is built records acore.UnresolvedSecretErroron the client. With that error present, the client does not connect (Connect), does not start a sign-in (every manual-login entry point), and does not refresh a token (RefreshOAuthTokenDirect). Nothing is dialled.unresolved secret reference ${keyring:my_api_key} in Headers[Authorization]: the secret is not available, so nothing was sent to the upstream. Add it with: mcpproxy secrets set my_api_key, then restart the server (mcpproxy upstream restart my-server)If a field mixes references, those that resolve are not named. The error classifies as
MCPX_CONFIG_MISSING_SECRET.health.ExtractMissingSecretrecognises the error, so the server shows Missing secret (unhealthy,needs_secret) with theset_secretaction and the reference name as the detail. It no longer shows green.DetermineTransportTypeon the resolved config, the same decisionConnectmakes). Each reference that resolves is still substituted, and other servers are unaffected. A stdio server keeps the existing behaviour for every field: it never sends itsheaders,urloroauthvalues, and a missing reference inenv,argsorworking_diris logged and used as written.${type:name}text in an HTTP server's URL, headers or OAuth settings is now refused rather than sent literally. That includes${env:NAME}for an unset variable. For${env:}the fix hint says to restart mcpproxy, because the env provider reads mcpproxy's own environment.references: ["${keyring:x}"]), never the field's value.mcpproxy upstream restartalready builds a new client, which resolves secrets again. Storing a secret through REST or the Web UI (NotifySecretsChanged) restarted only servers that referenced it inenvorargs. It now also restarts servers that reference it in the URL, headers, working directory or OAuth settings. It also skips disabled servers, because a restart enables a disabled server; until now, storing or deleting a secret re-enabled a disabled stdio server that used it.docs/errors/MCPX_CONFIG_MISSING_SECRET.mdgains "HTTP upstreams: nothing is sent" and the restart step.Testing
internal/runtime/unresolved_header_secret_test.goruns through the normal configuration and connection path (runtime.New→StartBackgroundInitialization). It uses a fake keyring and real streamable-HTTP MCP upstreams that record every request and its headers. The server under test hasAuthorization: Bearer ${keyring:f9-missing}(missing) andX-Present: ${keyring:f9-present}(present). The test checks that:last_errornames the reference, the field and the fix;set_secretwith detailf9-missing.After the key is added, the server connects with
Bearer <value>and the validX-Presentsubstitution. No request ever carries${keyring:. This is run in two subtests: one throughRestartServer, one throughNotifySecretsChanged(storing the secret through the API). Every log entry is checked for the secret values.On
mainthe same test fails: the upstream receivedAuthorization: Bearer ${keyring:f9-missing}. The API subtest also fails if the header scan is removed fromserverReferencesSecret.internal/upstream/core/unresolved_secrets_test.gocovers:OAuth.ClientSecretcases;envreference and a header whose references all resolve: neither is blocked.Race tests pass for
./internal/upstream/...,./internal/runtime,./internal/httpapi,./internal/secret/...,./internal/health/...,./internal/diagnostics/...and./internal/config/....golangci-lintwith.github/.golangci.yml, bare and with--build-tags=server, reports 0 new issues.Independent review: an Opus 5.5 agent with fresh context, two rounds.
${env:}hint, skipping disabled servers, the provider reason restored in the log, the log checks covering array fields, both sign-in flows tested with OAuth applicable, the race fallback, and the docs.TestTransientCodes_StayRetryablepins it deliberately) and the gaps below that predate this PR.3baa5d2fc.Not covered / known gaps:
mcpproxy secrets setrun while no core is running needsmcpproxy upstream restart <server>; the error says so.secret.Resolver.ExtractConfigSecrets(the Web UI's secret listing) does not walk maps, so header references are not listed there. This predates this PR and is unchanged.serverReferencesSecretdoes not scan theisolationfields.AuthBroker.ClientSecretis not expanded on the broker path.httpapi.checkMissingSecretsignores headers.secret_file_dirspolicy for${file:}references and its own connect-time refusal. The two touch nearby code ininternal/upstream/core; whichever merges second may need a small rebase.