Skip to content

fix(lib-pairing): keep credentials out of the pairing message logs - #175

Open
munishchouhan wants to merge 1 commit into
masterfrom
fix/COMP-2963-pairing-message-redaction
Open

munishchouhan wants to merge 1 commit into
masterfrom
fix/COMP-2963-pairing-message-redaction

Conversation

@munishchouhan

@munishchouhan munishchouhan commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

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.

On the default WebSocketTowerConnector path, lib-pairing 1.2.0 still logs the whole message through its @ToString. Failed to send message= (ERROR) prints auth:Bearer <JWT> and the refresh_token body, and Receiving message= (TRACE) prints this same response body and set-cookie.

Problem

PairingWebSocket renders whole messages into its logs at five sites:

Line Level Statement
:131 TRACE Sending message=${msg}
:134, :147, :167 ERROR Failed to send message=${msg}
:173 TRACE Receiving message=$message

ProxyHttpRequest and ProxyHttpResponse were @ToString(includeNames = true) over every field, so those statements printed:

  • auth — the Bearer <JWT> the caller is authenticating with
  • body — grant_type=refresh_token&refresh_token=... on the request, and the AccessRefreshToken JSON (access_token + refresh_token) on the response
  • headers — including the Set-Cookie carrying the freshly minted JWT and JWT_REFRESH_TOKEN

Three 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 masks auth, body and the credential headers through StringUtils.redact, while msgId, method, uri and status stay 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, and toLowerCase() fails open under a Turkish default locale, where AUTHORIZATION lowercases to a dotless ı and the match silently misses. The redacted set is authorization, 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 as gra****. 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, and PairingMessageEncodeStrategyTest and the two serialisation specs still pass.

Tests

New ProxyHttpMessageRedactTest: the request's bearer and refresh-token body, and the response's AccessRefreshToken body and set-cookie, none survive toString(), while msgId, method, status and content-type do. Plus a case-insensitivity table for the header names.

./gradlew :lib-pairing:test — 43 tests across 6 specs, 0 failures.

Release

VERSION is 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:70 needs bumping off lib-pairing:1.2.0 to pick it up.

🤖 Generated with Claude Code

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>
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.

1 participant