Skip to content

mcpx(logging): keep keyword-pair URL values readable in Redact (#2463) - #2833

Merged
dezren39 merged 2 commits into
mainfrom
queue/3683-2463-redact-url
Oct 30, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/3683-2463-redact-url

Conversation

@dezren39

@dezren39 dezren39 commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Fixes #2463 — PR #1737's Redact mangled URL values carried under a sensitive keyword.

The bug

sensitiveValue's keyword-pair alternative matches a whole KEY=VALUE token before the URL-userinfo alternative can run. The replacement func then applied the userinfo reconstruction to that pair match: it truncated at the first colon after :// — the port colon of a credential-free URL — producing a fabricated <elided>@ and dropping host/port/path:

  • AUTH_URL=https://auth.example.com:8443/callback → AUTH_URL=https://auth.example.com:<elided>@
  • TOKEN_URL=https://deploy:s3cr3tpw@example.com:8443/path → TOKEN_URL=https://deploy:<elided>@ (host/port/path lost)

The fix

The replacement func now decides URL-containing matches by shape (redactURLMatch in internal/logging/trace.go): it locates the scheme, preserves any pair prefix (KEY= / KEY:) or bearer lead-in, and then — no userinfo, or userinfo without a password → the URL is credential-free and kept verbatim; userinfo with a password → only the password is elided, keeping scheme, user, host, port and path. The userinfo reconstruction now applies only to userinfo-shaped matches, as #2463's acceptance requires. No regex changes; whole-value elision for sensitive names is untouched; no generic high-entropy detection added (out of scope per #1710).

Tests

  • Codex P1 (head 84be0e32): keeping a keyword-pair URL readable must not keep a secret with it. The preserved URL is scanned for credentials of its own — credentialInURL (bearer tokens, token literals) applies to the path, credentialInQuery (KEY=VALUE pairs) applies only from the ?/# separator so auth.example.com:8443 is not read as a pair. AUTH_URL=https://example.com/callback?token=abc123 records as AUTH_URL=https://example.com/callback?token=<elided>. The credential shapes are spelled once as constants and composed into sensitiveValue, credentialInURL and credentialInQuery, so the pair keywords cannot drift between them; pinned in the same test.
  • New TestRedactKeywordPairURLValues pins all four shapes (ported credential-free URL, user-only userinfo, password userinfo under a keyword, pair in surrounding context) — reproduced failing 4/4 on main with exactly the mangled outputs mcpx(logging): PR #1737's Redact mangles URL values under a sensitive keyword — port printed as an elided password, rest of URL dropped #2463 reported, now passing.
  • Full go test ./internal/logging/ green on the laptop, including every PR mcpx(logging): fix Redact leaks — full JWT elision, reconciled KEY=VALUE keywords, URL userinfo passwords (#1710) #1737 regression (TestRedactElidesFullJWTAndReconciledKeywords, TestRedactURLUserinfoKeepsTheRestOfTheURL, …). CI runs the same package suite.

Queue task 3683 · repo-worker-code Lane A.


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 30, 2026 21:19
@coderabbitai

coderabbitai Bot commented Oct 30, 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 7 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: 49d816b9-c8fe-4453-bb35-91074471dfe8
Commits

Reviewing files that changed from the base of the PR and between dc9b117 and 84be0e3.

Files selected for processing: 2
  • pkgs/mcpx/internal/logging/redact_test.go
  • pkgs/mcpx/internal/logging/trace.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

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 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-30T21:47:37.918120Z 84be0e3 New commits
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0fa59dfb34

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkgs/mcpx/internal/logging/trace.go Outdated
Comment on lines +261 to +263
if at < 0 {
// No userinfo: nothing in this URL is a credential.
return m, true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Redact recognized credentials within preserved URL values

When a keyword-pair URL contains a recognized credential in its query or path, this return bypasses redaction of that credential. For example, Redact("MCPX_SCRIPT_ENV", "AUTH_URL=https://example.com/callback?token=abc123") now returns the input verbatim, whereas the previous implementation returned AUTH_URL=<elided>. Because the keyword-pair regex consumes the entire URL, ReplaceAllStringFunc never separately examines the nested token=abc123 match, exposing it in recorded environment metadata. Preserve URL readability while still redacting recognized credentials within it, and cover this permutation with a regression test.

AGENTS.md reference: pkgs/mcpx/internal/AGENTS.md:L9-L10

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 84be0e32. The preserved URL is now scanned for credentials of its own: credentialInURL (bearer tokens and token literals) applies to the path, and credentialInQuery (KEY=VALUE pairs) applies only from the ?/# separator onward, so a hostname such as auth.example.com:8443 is not mistaken for a pair. AUTH_URL=https://example.com/callback?token=abc123 now records as AUTH_URL=https://example.com/callback?token=<elided> — the URL context survives, the credential does not. Pinned in TestRedactKeywordPairURLValues alongside the path-literal case. The credential shapes are spelled once as constants and composed into all three matchers, so the pair keywords cannot drift between Redact and the nested scan.

Keeping a keyword-pair URL readable must not keep a secret with it: a
token pair in its query, or a token literal in its path, is elided now
while the URL context survives. The credential shapes are spelled once
and composed into every matcher so they cannot drift apart.
@dezren39
dezren39 merged commit 8808dfa into main Oct 30, 2026
9 checks passed
@dezren39
dezren39 deleted the queue/3683-2463-redact-url branch October 30, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mcpx(logging): PR #1737's Redact mangles URL values under a sensitive keyword — port printed as an elided password, rest of URL dropped

1 participant