Repository navigation
fix: redact credential headers from log dumps [COMP-2963] - #1292
Merged
Merged
Conversation
RegHelper.dumpHeaders wrote every header value verbatim, so credentials reached the logs through each of its callers. Redact Authorization, Proxy-Authorization, Cookie and Set-Cookie at that one point, matching header names case-insensitively since HTTP header names are. The Set-Cookie case is the serious one: the Platform token-refresh response carries the newly minted JWT and refresh token there, and TowerConnector dumped those headers at TRACE. That same response has an AccessRefreshToken body holding both tokens again, logged in full at TRACE and truncated to 500 chars at DEBUG, which is the default level -- so stop logging the refresh body at any level. JwtAuth.toString rendered the full bearer and refresh token whenever TRACE was enabled; truncate unconditionally, as PlatformId.toString already does. That covers all thirteen sites that render a JwtAuth. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
pditommaso
reviewed
Nov 19, 2026
pditommaso
left a comment
Collaborator
There was a problem hiding this comment.
Looks good: each change cuts down what gets logged, and every dumpHeaders caller is covered by the one function. A few proposed changes:
- Use the existing
StringUtils.redactfor secrets. Wave already has a helper for masking secrets in logs (io.seqera.wave.util.StringUtils.redact, used inBootstrap,RegistryAuthServiceImpl,RegistryCredentialsFactoryImpl,ContainerRegistryKeys, and others).trunc(value,25)only shortens a string, it doesn't hide it: that's harmless for a JWT, whose first ~20 chars are the standard header, but it would expose most of a short opaque refresh token. See the inline suggestion onJwtAuth. - Optional:
dumpHeaderscould printStringUtils.redact(val)rather than the[redacted]literal, so header masking matches the rest of the logs, e.g.Authorization=Bea****, which also keeps the scheme visible.[redacted]is fine too, so take or leave it (the test expectations would change accordingly). - Follow-up:
PlatformId.toString()has the sametrunc(accessToken,25)thatJwtAuthnow copies. It should useredacttoo: either a one-line addition here or the follow-up ticket.
Review feedback. trunc shortens a value, it does not hide it: at 25 characters a JWT still shows its header and the start of its payload. Use StringUtils.redact in JwtAuth.toString, which keeps 3 characters, and in PlatformId.toString, which had the same 25-character truncation of the Platform access token. Also give dumpHeaders' early exit its missing return. That branch was not merely dead: TowerConnector passes resp.headers, which can be null, so the fall-through reached a for loop over null and threw inside the token refresh path. The new test used /v1alpha3/builds, a route that does not exist on master; the path is irrelevant to the assertion, so use /v1alpha1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
cristianrcv
approved these changes
Nov 19, 2026
jordeu
approved these changes
Nov 19, 2026
…963] Review feedback. Print StringUtils.redact(val) rather than a literal, so header masking matches the rest of the logs and the scheme stays visible (Authorization=Bea****). Add x-registry-auth to the redacted set: it carries base64 registry credentials and arrives inbound, as its presence in RegistryProxyService's cacheable headers shows. Pin the guarantee in tests: nothing asserted that JwtAuth.toString and PlatformId.toString hide their tokens, which is how the level-dependent trunc0 survived unnoticed. 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.
Closes part of COMP-2963. The storage half of that story — encrypting Platform credentials at rest in Redis — is split out to COMP-3140 and is not in this PR.
Problem
RegHelper.dumpHeaderswrote every header value verbatim, so any credential in a header reached the logs through each of its callers.Two paths matter:
TowerConnector, at TRACE. The Platform token-refresh response carries the newly mintedJWTandJWT_REFRESH_TOKENinSet-Cookie—parseTokens()reads them from exactly there — and that dump printed them in full.ErrorHandlerand the two deny-filters, at WARN/ERROR. Both levels are on at theio.seqera: DEBUGdefault, so any inboundAuthorizationheader was logged verbatim. On master that is a registry-proxy credential; once the read API lands,ReadApiControlleraccepts a Platform bearer in that header, so this closes the exposure ahead of it.The same refresh response also has an
AccessRefreshTokenbody holding both tokens again — verified against Platform's ownOauthControllerTest, which deserializes/oauth/access_tokeninto that type. It was logged in full at TRACE and truncated to 500 chars at DEBUG, the default level. Redacting only the header would have left the identical token pair one field over.Separately,
JwtAuth.toString()returned the full bearer and refresh token whenever TRACE was enabled, via atrunc0helper that consulted the log level.Change
RegHelper.dumpHeadersredactsauthorization,proxy-authorization,cookieandset-cookie. Matching is case-insensitive viaequalsIgnoreCase— HTTP header names are case-insensitive, andtoLowerCase()would misbehave under a Turkish default locale, whereAUTHORIZATIONlowercases to a dotlessıand the match silently fails open.TowerConnectorno longer logs the refresh response body at any level.JwtAuth.toString()truncates unconditionally, matchingPlatformId.toString().trunc0and the now-unused@Slf4jare gone. This covers all thirteen sites that render aJwtAuth.www-authenticateis deliberately not redacted: registry challenges carry realm, service and scope, which are needed on the proxy path and were not shown to carry a secret.Tests
RegHelperTestgains two cases — one pinning the exact dump output including an uppercasePROXY-AUTHORIZATION, one through theio.micronaut.http.HttpRequestoverload, which is the path the default-level callers use.Green:
RegHelperTest27,TowerClientTest59,TowerClientHttpTest21,JwtAuthTest3,JwtAuthStoreTest2,JwtRefreshParamsTest1,DenyCrawlerFilterTest2,DenyPathsFilterTest5 — 0 failures.Known follow-up, not in this PR
dumpHeadersis not yet the only door. Four sites render headers into logs without it, two carrying the inbound bearer:RateLimiterFilter.groovy:136— raw${request.getHeaders().asMap()}at TRACEProxyClient.groovy:355-370—traceResponseisdumpHeadershand-rewrittenTraceSlowEndpointPublisher.java:118-127— a third copy at DEBUG, opt-in via a property set in no ymlTowerConnector.groovy:231—${resp}rendersProxyHttpResponse's@ToStringover the whole header map and bodyRegHelper.isSensitiveHeader(name)is public so routing them through it is a small change. Raising separately to keep this PR to one concern.Also pre-existing and untouched:
RegistryAuthServiceImpl:217logs full base64 registry credentials at TRACE, and:189uses the single-argtrunc, which returns an entire first line.🤖 Generated with Claude Code