Repository navigation
fix(lib-pairing): keep credentials out of the pairing message logs - #175
Open
munishchouhan wants to merge 1 commit into
Open
munishchouhan wants to merge 1 commit into
munishchouhan wants to merge 1 commit into
Conversation
PairingWebSocket renders whole messages into its logs: "Sending message=" and "Receiving message=" at TRACE, and "Failed to send message=" at ERROR, which is on at the default level. ProxyHttpRequest and ProxyHttpResponse were @tostring over every field, so those statements printed the bearer in `auth`, the `grant_type=refresh_token&refresh_token=...` request body, the AccessRefreshToken response body and the Set-Cookie carrying the freshly minted JWT and refresh token. Give both messages an explicit toString that masks `auth`, `body` and the credential headers through StringUtils.redact, leaving msgId, method, uri and status readable. Fixing it on the message rather than at each log site covers the statements that exist and any added later. Also redact the license token in PairingWebSocket's four validation failure logs, two of which are at ERROR. Reported by @jordeu reviewing seqeralabs/wave#1292, which removes the same tokens from Wave's own logs; this is the library half. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Raised from @jordeu's review of seqeralabs/wave#1292, which removes the same tokens from Wave's own logs. This is the library half. Tracked under COMP-2963.
Problem
PairingWebSocketrenders whole messages into its logs at five sites::131Sending message=${msg}:134,:147,:167Failed to send message=${msg}:173Receiving message=$messageProxyHttpRequestandProxyHttpResponsewere@ToString(includeNames = true)over every field, so those statements printed:auth— theBearer <JWT>the caller is authenticating withbody—grant_type=refresh_token&refresh_token=...on the request, and theAccessRefreshTokenJSON (access_token+refresh_token) on the responseheaders— including theSet-Cookiecarrying the freshly mintedJWTandJWT_REFRESH_TOKENThree of the five are at ERROR, which is on at the default level, so this does not need TRACE to fire.
Change
Both message types get an explicit
toString()that masksauth,bodyand the credential headers throughStringUtils.redact, whilemsgId,method,uriandstatusstay readable. Fixing it on the message rather than at each log site covers the statements that exist today and any added later.Header matching uses
equalsIgnoreCase— HTTP header names are case-insensitive, andtoLowerCase()fails open under a Turkish default locale, whereAUTHORIZATIONlowercases to a dotlessıand the match silently misses. The redacted set isauthorization,proxy-authorization,cookie,set-cookie,x-registry-auth, matching the set Wave #1292 uses.Every body is redacted rather than only the ones known to be a credential —
grant_type=refresh_token&...renders asgra****. Guessing which bodies are secret is how the response body got missed in the first place.Also redacts the license token in
PairingWebSocket's four validation-failure logs (:225,:232,:240,:243), two of them at ERROR. Not in the original report, but the same class of leak in the same file.This only affects
toString(). Moshi serialisation is untouched, andPairingMessageEncodeStrategyTestand the two serialisation specs still pass.Tests
New
ProxyHttpMessageRedactTest: the request's bearer and refresh-token body, and the response'sAccessRefreshTokenbody andset-cookie, none survivetoString(), whilemsgId,method,statusandcontent-typedo. Plus a case-insensitivity table for the header names../gradlew :lib-pairing:test— 43 tests across 6 specs, 0 failures.Release
VERSIONis bumped to 1.2.1 with a changelog entry and the README reference updated, but the title deliberately carries no[release]marker — that is the maintainers' call. Once 1.2.1 publishes,wave/build.gradle:70needs bumping offlib-pairing:1.2.0to pick it up.🤖 Generated with Claude Code