Skip to content

fix(mcpx): mcpauth expansion — only ${VAR} expands, literal $ survives (#1662) - #3050

Merged
dezren39 merged 1 commit into
mainfrom
queue/4190-1662-literal-dollar
Oct 31, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/4190-1662-literal-dollar

Conversation

@dezren39

@dezren39 dezren39 commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Fixes #1662 (queue task 4190; contract pinned by triage task 1838).

mcpauth resolved credentials with os.Expand, which treats $2, $$, $5 and $HOME as variable references — a literal password like hunter$2 or pa$$word was silently rewritten before reaching the server, a $-segment naming a set variable was spliced into the credential, and phantom names landed in Resolved.Missing (which pool.resolveAuth turns into a hard refusal naming a variable nobody referenced).

This replaces the expansion step in ResolveWith with a scanner implementing the pinned contract:

  • Only the braced ${VAR} shape (letters/digits/underscore name, closing brace) is a reference and expands through the lookup.
  • Every other $ is literal text, byte-for-byte: bare $VAR, $2, $$, $5, a trailing $, and ${...} shapes that are not a plain name (e.g. ${VAR:-default}) all reach the transport exactly as configured.
  • Escape: $${VAR} renders the literal text ${VAR} and references nothing.
  • Missing now names only genuine ${VAR} references the lookup could not supply.

The contract is documented in the package doc and on the Token field. Describe/redactRef are unchanged — their display rules are pinned by existing tests and are a separate surface from expansion.

Tests: new expand_test.go adapts the prepared probe (goal hidden_files probe-2026-10-28-laneB-authexpand) — the BUG cases (basic password $<digit>, $$, $NAME-that-is-set; env value with a price) now pass, the CTRL cases (braced reference expands, genuine missing reported) keep passing, plus escape/invalid-brace/mixed/header shapes. Laptop: go test ./internal/mcpauth/ ./internal/pool/ pass; gofmt/vet clean.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner October 31, 2026 12:31
@coderabbitai

coderabbitai Bot commented Oct 31, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f772e355-4d97-43a5-9eca-07d2d4f27dc8
Commits

Reviewing files that changed from the base of the PR and between 1f8ab4f and c4836ef.

Files selected for processing: 2
  • pkgs/mcpx/internal/mcpauth/expand_test.go
  • pkgs/mcpx/internal/mcpauth/mcpauth.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T12:33:01.356188Z c4836ef PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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

Labels

None yet

Projects

None yet

1 participant