Repository navigation
Description
mcpx(logging): PR #1737's Redact mangles URL values under a sensitive keyword — a port is printed as an elided password and the rest of the URL is dropped
Finding
PR #1737 (merged, fixes #1710) taught Redact to elide URL userinfo passwords. Its replacement function (pkgs/mcpx/internal/logging/trace.go:214 on current main 5a34fa70) decides "this match is a URL userinfo match" purely from strings.Index(m, "://") — but the KEY=VALUE alternative of sensitiveValue (trace.go:189) comes first in the alternation and consumes a whole URL as its \S+ value whenever the pair's name contains a sensitive keyword (auth, token, key, …). For such a match the function:
- mistakes the URL's port colon (or the userinfo colon) for the marker it wants, and
- reconstructs only
prefix + user + ":" + "<elided>@", silently discarding the remainder of the match — host, port and path for a userinfo URL; the path (plus a fabricated@) for a credential-free URL.
The PR's own keep-case — a bare userinfo URL keeps scheme, user, host, port and path — only holds when the URL alternative is the one that matched.
Evidence
- PR: mcpx(logging): fix Redact leaks — full JWT elision, reconciled KEY=VALUE keywords, URL userinfo passwords (#1710) #1737 — merge
ee07ac6cad82ec5ee0484d8545b15a76a71791ee, commit2d5da5a7. - Current main
5a34fa70:sensitiveValueatpkgs/mcpx/internal/logging/trace.go:189-200(pair alternative before the userinfo alternative);Redact's URL branch attrace.go:214-220. - Probe (verbatim regex +
Redactcopied from current main, run on the laptop:~/git/fleet/probe-2026-10-29-laneB-redact/main.go):Redact("MCPX_SCRIPT_ENV", "AUTH_URL=https://auth.example.com:8443/callback")→"AUTH_URL=https://auth.example.com:<elided>@"— no credential anywhere in the input, yet the output presents the port8443as an elided password, invents a@, and drops/callback.Redact("MCPX_SCRIPT_ENV", "TOKEN_URL=https://deploy:s3cr3tpw@example.com:8443/path")→"TOKEN_URL=https://deploy:<elided>@"— password elided, but host, port and path are lost (the bare-URL control below keeps all of them).- Controls behave: bare
https://deploy:s3cr3tpw@example.com:8443/path→https://deploy:<elided>@example.com:8443/path;SESSION=abc123sessionvalue→SESSION=<elided>;AUTH_URL=https://auth.example.com/callback(no port) →AUTH_URL=<elided>.
Why it matters
Redact is the logging safety boundary for mcpx: its outputs are what operators read when diagnosing from traces. A redactor that fabricates credential-looking output (host:<elided>@) for a credential-free URL sends diagnosis in the wrong direction, and one that silently truncates the non-secret remainder of a value destroys exactly the context the per-match (rather than whole-value) design exists to preserve. Any *_URL/AUTH_*/TOKEN_* pair carried inside MCPX_SCRIPT_ENV-style values — the PR's own motivating case — with a port or userinfo hits this.
Acceptance criteria
- Regression tests in
redact_test.go: a sensitive-keyword pair whose value is a URL with a port and no userinfo keeps the URL readable with only the genuinely sensitive part elided (no fabricated<elided>@, no dropped path); a keyword pair whose value is a userinfo URL elides only the password and keeps scheme, user, host, port and path — matching the bare-URL keep-case from PR mcpx(logging): fix Redact leaks — full JWT elision, reconciled KEY=VALUE keywords, URL userinfo passwords (#1710) #1737. - The URL-userinfo reconstruction is applied only when the match actually came from the userinfo alternative (or the pair case is handled before the URL check), not on any match containing
://. - All PR mcpx(logging): fix Redact leaks — full JWT elision, reconciled KEY=VALUE keywords, URL userinfo passwords (#1710) #1737 regression tests (full JWT, reconciled keywords, bare userinfo, credential-free URLs) still pass, in CI.
Found by pr-diff-review lane B reviewing PR #1737. Not a leak — nothing sensitive is exposed; the flaw is corruption/fabrication of the redacted output. #1710 (closed) covered the leak direction only.
Activity
developing-today commentedon Oct 29, 2026
CODE-1260
dezren39 commentedon Oct 29, 2026
🤖 Agent note · filed
4 remaining items
mcpx(logging): elide credentials nested in keyword-pair URLs (#2463)
dezren39 commentedon Oct 30, 2026
🤖 Agent note · picked up
pr_openedcheckpoint)repo-health-code-pilot), revalidated against fresh GitHub state0fa59dfbwas green, but Codex left an unresolved P1: preserving keyword-pair URLs verbatim meant a credential nested in the URL (?token=abc123) was recorded verbatim, where the old code returned<elided>. Fixed in84be0e32: the credential shapes are now spelled once as constants and composed intosensitiveValue,credentialInURL(bearer + token literals, applied to path) andcredentialInQuery(KEY=VALUE pairs, applied only from?/#so a hostname likeauth.example.com:8443is not mistaken for one). Nested credentials are elided while the URL context survives.84be0e32· issue mcpx(logging): PR #1737's Redact mangles URL values under a sensitive keyword — port printed as an elided password, rest of URL dropped #2463mcpx(logging): keep keyword-pair URL values readable in Redact (#2463)
dezren39 commentedon Oct 30, 2026
🤖 Agent note · done
repo-health-code-pilot), resumed frompr_opened8808dfad.Redactnow decides URL-containing matches by shape: a keyword-pair URL that carries no credential stays readable with no fabricated<elided>@and no dropped path; a userinfo URL under a keyword elides only the password, keeping scheme/user/host/port/path. Codex's P1 (nested credential inside a preserved URL) is fixed in84be0e32: nested bearer tokens, token literals in the path, and KEY=VALUE pairs in the query are elided while the URL context survives, and the credential shapes are spelled once so the matchers cannot drift.TestRedactKeywordPairURLValuespins all eight shapes.go test ./internal/logging/ -count=1and-race -shuffle=on -count=5pass on the laptop; CI green on84be0e32(build, stress on changed tests, time budget); all PR mcpx(logging): fix Redact leaks — full JWT elision, reconciled KEY=VALUE keywords, URL userinfo passwords (#1710) #1737 regressions still pass.8808dfad· issue mcpx(logging): PR #1737's Redact mangles URL values under a sensitive keyword — port printed as an elided password, rest of URL dropped #2463 (auto-closed by the PR)