Repository navigation
Description
Summary
mcpauth expands every credential field with os.Expand, so a literal credential containing a $ segment is silently rewritten: $2, $$, $5 are eaten as special shell variables, and $NAME splices the daemon's own environment into the credential. Literal credentials are an expected shape in these fields — redactRef exists precisely because a config may hold a literal secret — yet any literal password/token/value containing $ followed by a letter, digit or shell-special character is corrupted, and the phantom variable name it invents lands in Missing, which the pool turns into a hard refusal naming a variable nobody referenced.
Evidence (verified on main 7eb930a, this run)
- pkgs/mcpx/internal/mcpauth/mcpauth.go:122-135 —
expandrunsos.Expand(v, …)unconditionally and appends the referenced name toout.Missingwhenever the looked-up value is empty. It is applied to bearerToken(:166), basicUsername/Password(:172), headerValue(:182), queryParamValue(:193) and every non-passthroughEnvvalue (:148). - Go's
os.Expandsemantics, read this run in the installed stdlib (~/tools/go/src/os/env.go:16-109):getShellNametreats a digit or one of* # $ @ ! ? -as a complete special-variable name, and otherwise consumes the longest[A-Za-z0-9_]run. So in a literal:hunter$2→hunter, with phantom variable2reported missing;pa$$word→paword, with phantom variable$reported missing;cost is $5(an env value) →cost is, phantom5;s3cret$HOME→s3cret+ the daemon's actual$HOMEvalue spliced in — no Missing entry, no error: the server silently receives a different password than the one configured and returns a 401 nobody can interpret, the exact failure this package's header says it exists to prevent.
- The phantom Missing is not advisory: internal/pool/pool.go
resolveAuth(:766-777) refuses the server outright whenlen(r.Missing) > 0, withauth: 2 not set in the daemon's environment— naming a "variable" that appears nowhere in the user's config. - Literals are expected in these fields:
redactRef(mcpauth.go:226-237) redacts any value that is not a$-reference as "(literal, redacted)", i.e.Describeis built for literal secrets sitting inToken/Password/Value. The documented expansion contract names only the braced form: Token's doc (:34-35) says "Expanded, so ${GITHUB_TOKEN} works". No doc found this run states that a bare$in a literal is also a reference, and there is no escape mechanism. - Existing tests cover only the
${VAR}forms (mcpauth_test.go:14, :26, :79, :83; resolvewith_test.go:19, :38) — no literal containing$is tested.
Disclosure: the prepared probe test (in the goal's hidden_files, probe-2026-10-28-laneB-authexpand/probe_laneb_test.go) was NOT executed this run — the laptop probe host was unreachable for the whole run (the tailnet SSH tunnel closes immediately; the same outage the previous three creator runs hit) and probes are never compiled on the sandbox. The verdicts above follow deterministically from os.Expand's source in the installed Go tree (cited above) traced through expand; triage should run the probe first and correct this evidence if any traced verdict differs.
Why it matters
Passwords and opaque tokens containing $ are ordinary. Today such a credential either (a) refuses the server before any request with an error naming a phantom variable (2, $, 5), sending the user hunting for a config entry that does not exist, or (b) worse, when the invented name happens to be set in the daemon's environment ($HOME, $USER, $PATH…), silently sends a different credential than configured — splicing daemon environment values into a secret and producing an undebuggable 401. Both outcomes violate the package's stated purpose: report credential problems "before a request rather than as a 401" (mcpauth.go:99-101).
Acceptance criteria
- A literal credential containing
$reaches the transport byte-for-byte as configured: regression tests for at least the$<digit>,$$, and$NAME-that-is-setshapes across basic password, bearer token and an env value (run the prepared probe first and correct the issue's evidence if any traced verdict differs). - The documented
${VAR}reference form — and any bare-$VARform triage decides to keep supporting — still expands, and a genuinely referenced unset variable is still reported inMissing(existing mcpauth tests pass unchanged, or are amended only where triage pins a deliberate contract change). - The expansion contract is written down where a config author will find it (the
Authfield docs and/or the package doc): which shapes are references, how a literal$is written, and whatMissingmeans. - No phantom names in
Missing: every name it reports is a reference the config author actually wrote in a recognised reference shape. - Full existing internal/mcpauth suite (and the pool auth tests, internal/pool/auth_test.go) pass on laptop or CI.
Activity
dezren39 commentedon Oct 28, 2026
🤖 Agent note · filed
22 remaining items
dezren39 commentedon Oct 31, 2026
🤖 Agent note · picked up (resume)
final: CI time budget(the one job still queued at park), basic lint, stress PR tests, plugin tests, docs build. Checking Codex findings/threads on this head, then merge -> close mcpx(mcpauth): literal credentials containing $ are silently rewritten by expansion — $2 and $$ are eaten, $HOME is spliced in, and the phantom name refuses the server as 'not set' #1662 -> complete fixed_merged.Merge pull request #3050 from developing-today/queue/4190-1662-litera…
dezren39 commentedon Oct 31, 2026
🤖 Agent note · done
final: CI time budget(the one job still queued when the previous lane parked); Codex review state on head c4836ef: no findings, none unresolved; 0 unresolved review threads; merge state CLEAN. Issue auto-closed by the merge.