fix: redact GitLab token from debug/warn logs in auth context - #645
Open
brennanneoh wants to merge 1 commit into
Open
fix: redact GitLab token from debug/warn logs in auth context#645brennanneoh wants to merge 1 commit into
brennanneoh wants to merge 1 commit into
Conversation
buildAuthHeaders() and getEffectiveApiUrl() logged the entire SessionAuth context object at debug/warn level, which includes the raw GitLab bearer token/PAT/job token. In REMOTE_AUTHORIZATION or GITLAB_MCP_OAUTH mode this runs on essentially every proxied tool call, so anyone with read access to logs at LOG_LEVEL=debug (a level the project's own docs recommend for troubleshooting) could harvest live GitLab access tokens for every active session. Log only non-sensitive fields (sessionId, header, apiUrl) instead of the full context object. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📜 Recent review details🔇 Additional comments (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAuthentication diagnostics now log selected session, header, and API URL fields instead of complete authentication context objects. ChangesAuthentication diagnostics
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
buildAuthHeaders()(index.ts) logged the entireSessionAuthcontext object at debug level vialogger.debug({ context: ctx }, ...). That object includes the raw GitLab bearer token / PAT / job token.getEffectiveApiUrl()had the identical pattern on its fallback path (logger.warn({ ctx }, ...)).sessionId,header,apiUrl) instead of the full context object.Why
Security issue:
buildAuthHeaders()runs on essentially every proxied tool call whenREMOTE_AUTHORIZATIONorGITLAB_MCP_OAUTHis enabled (multi-tenant HTTP/stateless server mode). WithLOG_LEVEL=debugset, which the project's own docs suggest for troubleshooting, anyone with read access to the resulting logs could harvest live GitLab tokens for every active session and reuse them directly against the GitLab API.Reported privately to the maintainer alongside a second, unrelated finding before opening this PR.
How tested
npx tsc --noEmitnpm run test:mock(all suites pass, includingnpm run test:remote-auth, which exercisessessionAuthStore/ session auth headers end to end)npm run test:consumer-smokeBreaking changes
None. Only log output changes; no behavior or API surface change.