Skip to content

fix(logs): mask the whole Bearer credential and unsigned JWTs - #1792

Merged
Dumbris merged 2 commits into
mainfrom
claude/competent-panini-fb070b
Oct 29, 2026
Merged

Dumbris merged 2 commits into
mainfrom
claude/competent-panini-fb070b

Conversation

@Dumbris

@Dumbris Dumbris commented Oct 26, 2026

Copy link
Copy Markdown
Member

Summary

Fixes two secret leaks in internal/logs/sanitizer.go that were already on main.

1. Bearer suffix leak (pattern order). The patterns run one after another over the rewritten string, and every mask inserts ***, which no pattern's character class accepts. github_token, openai_key and anthropic_key ran before bearer_token. So when a Bearer credential started with a known key prefix, the key pattern masked it first, and bearer then stopped at the inserted ***:

before: Bearer sk-AbCdEf1234567890GhIjKlMnOpQrStUvWxYz0123456789.EXTRA_SECRET
     -> Bearer sk-A***Ab***89.EXTRA_SECRET
after:  -> Bearer sk-A***ET

The same thing could happen inside a JWT: a key-shaped run after a - in a segment got masked before jwt ran, and the payload and signature were logged. The fix runs bearer_token, then jwt, before the key-specific patterns. A comment above the patterns now states the ordering rule.

2. Unsigned JWT (alg: none). eyJhbGciOiJub25lIn0.eyJzdWIiOiIxIn0. has an empty third segment, and the trailing \b could never match after a ., so the payload was logged in clear. The third segment is now [A-Za-z0-9\-_]* and the trailing \b is gone. The output is header.***.***.

Existing mask formats are unchanged. That includes the tests from #1760, #1761 and #1762. A credential after Bearer now gets the Bearer mask instead of the key mask.

Testing

  • New internal/logs/sanitizer_pattern_order_test.go: Bearer + sk-/sk-proj-/ghp_/sk-ant- suffix, a JWT with a key-shaped run inside it, and an unsigned JWT in four contexts. All of these failed before the fix.
  • go test -race ./internal/logs/ passes.
  • golangci-lint v2 (.github/.golangci.yml) reports 0 issues, both bare and with --build-tags server.
  • Cross-review (opencode gpt-6.1-sol, high): CLEAN.

🤖 Generated with Claude Code

Patterns run sequentially over the rewritten string and every mask inserts
"***", which no pattern's character class accepts. github_token/openai_key/
anthropic_key ran before bearer_token, so "Bearer sk-...<rest>" was masked at
the key and bearer stopped at the inserted mask, logging <rest> in clear. The
same applied to a key-shaped run after a '-' inside a JWT segment.

Run bearer_token, then jwt, before the key-specific patterns. Allow an empty
JWT signature segment (alg: none) and drop the trailing \b that made such a
token unmatchable, so its payload is masked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 46a3fc9
Status: ✅  Deploy successful!
Preview URL: https://df6f6616.mcpproxy-docs.pages.dev
Branch Preview URL: https://claude-competent-panini-fb07.mcpproxy-docs.pages.dev

View logs

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

📦 Build Artifacts

Workflow Run: View Run
Branch: claude/competent-panini-fb070b

Available Artifacts

  • archive-darwin-amd64 (32 MB)
  • archive-darwin-arm64 (29 MB)
  • archive-linux-amd64 (20 MB)
  • archive-linux-arm64 (18 MB)
  • archive-windows-amd64 (32 MB)
  • archive-windows-arm64 (28 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (28 MB)
  • installer-dmg-darwin-arm64 (25 MB)
  • smart-mcp-proxymcpproxy-goMSKUDJ.dockerbuild (0 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 40317521543 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 70.00000% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/logs/sanitizer.go 70.00% 3 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

…ni-fb070b

# Conflicts:
#	internal/logs/sanitizer.go
@Dumbris
Dumbris merged commit 56bd59d into main Oct 29, 2026
47 checks passed
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.

2 participants