Skip to content

Do not log session ids, access tokens and password attributes - #1127

Open
vharseko wants to merge 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:fix/sensitive-token-logging
Open

vharseko wants to merge 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:fix/sensitive-token-logging

Conversation

@vharseko

Copy link
Copy Markdown
Member

Three of our own components wrote credentials into log files:

  • openam-mcp-server AuthInterceptor logged the OpenAM session id at INFO when refreshing a near-expired token (both the username/password and the OAuth paths) and the OAuth2 access token at WARN when /oauth2/userinfo rejected it.
  • openam-cassandra-cts TokenStorageAdapter logged the whole CTS Token (Token.toString() prints coreTokenId and every attribute) when a field could not be read during update.
  • openam-cassandra-datastore Repo logged the full attribute map on setAttributes failure and in setBinaryAttributes; that map carries userPassword for Membership self-registration and OAuth account creation.

A session id or access token in a log file is enough to hijack the session, so:

  • AuthInterceptor.maskToken() / TokenStorageAdapter.maskTokenId() keep a 4-character prefix and replace the rest with *** (short values become ***).
  • Repo logs keySet() only.
  • AuthInterceptorTest attaches a logback ListAppender and asserts the raw tokens never appear in the captured messages (both refresh paths and the invalid-userinfo path); new TokenStorageAdapterTest covers the mask.

Closes CodeQL java/sensitive-log alerts #243, #246, #247, #252, #270, #271.

AuthInterceptor (openam-mcp-server) wrote the OpenAM session id at INFO
when refreshing a near-expired token and the OAuth2 access token at WARN
when userinfo rejected it; the Cassandra CTS adapter logged the whole CTS
Token (tokenId included) when a field could not be read, and the Cassandra
IdRepo logged the full attribute map - userPassword included - when
setAttributes/setBinaryAttributes failed. A session id or token in a log
file is enough to hijack the session.

Log a masked prefix of the token instead, and only attribute names for the
IdRepo. Tests capture the logger output and assert the raw values are absent.

Closes CodeQL alerts java/sensitive-log OpenIdentityPlatform#243, OpenIdentityPlatform#246, OpenIdentityPlatform#247, OpenIdentityPlatform#252, OpenIdentityPlatform#270, OpenIdentityPlatform#271
@vharseko vharseko added java Pull requests that update java code security Security fix or hardening (CVE, GHSA, XSS/CSRF/SSRF) tests Test suite: coverage, fixtures, or test infrastructure labels Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java Pull requests that update java code security Security fix or hardening (CVE, GHSA, XSS/CSRF/SSRF) tests Test suite: coverage, fixtures, or test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants