Skip to content

fix(security): keep the login password out of the shared session map (#2341) - #2389

Merged
buggtb merged 2 commits into
developmentfrom
fix/2341-session-password
Nov 18, 2026
Merged

buggtb merged 2 commits into
developmentfrom
fix/2341-session-password

Conversation

@buggtb

@buggtb buggtb commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Summary

The plaintext login password is no longer stored in SessionService.sessionHolder or returned by getAllSessionObjects(); it is kept (only for pass-through datasources) as a wipeable char[] behind a dedicated accessor.

Root cause

createSession put the submitted password in the per-principal session map (a String, inserted only if the principal was absent), the map lived on a singleton for the JVM's life (only logout()/clearSessions() removed it, not HTTP-session expiry), and getAllSessionObjects() returned it to ~20 callers that only read username/roles. A rotated password was never refreshed.

What consumed it

Only SecurityAwareConnectionManager.handlePassThrough() (datasources with security.type=passthrough). Every other caller reads username/roles.

Fix

  • Credential held in a separate ConcurrentHashMap<principal, char[]>; getSession(), getAllSessionObjects() and login()'s return value strip any password key.
  • New ISessionService.passthroughCredential() (default null); handlePassThrough reads only that.
  • Replaced on every login (fixes the stale-after-rotation bug), zeroed on logout/clearSessions, and zeroed when the HTTP session ends via a new SessionSecretCleanupListener registered in web.xml (SessionService.httpSessionDestroyed).
  • -Dsaiku.passthrough.retainCredential=false stops retaining it altogether. Documented in docs/operator-hardening.md.

Decision for the maintainer: the issue suggests caching only when a pass-through datasource exists. The datasource list is workspace- and role-scoped and cannot be read reliably at login, and guessing wrong would silently break pass-through, so the default keeps the credential (now contained and wiped) and the property opts out. Say if you want the default flipped, or an auto-detect wired in.

Overlap: #2338, #2339 and #2345 are separate PRs on the same login/session code, each based on development.

Test plan

  • acceptance/2341/spec.json (command spec, node check.mjs, a source-level contract check because the cache has no HTTP surface) as the first commit; verified red on the base tree locally
  • mvn -pl saiku-core/saiku-web -am test -Dtest='SessionService*Test,SecurityAwareConnectionManager*Test,SessionResourceTest' green, including new SessionServicePassthroughSecretTest (no retention when disabled, accessor-only, logout wipe, re-login replaces, session-destroy wipe) and an updated pass-through test
  • spotless:check on saiku-web and saiku-service
  • existing persistence test keeps the on-disk map password-free

Closes #2341

🤖 Generated with Claude Code

buggtb and others added 2 commits November 12, 2026 17:16
)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…2341)

SessionService cached every user's plaintext login password as a String in a
singleton map for the life of the JVM and returned it from getAllSessionObjects()
to ~20 callers; a later login by the same principal never refreshed it.

The credential is now a char[] in a separate map, readable only through
ISessionService.passthroughCredential() (its single consumer is the pass-through
connection path), replaced on re-login, zeroed on logout and when the HTTP session
ends (new HttpSessionListener). saiku.passthrough.retainCredential=false stops
retaining it for deployments without pass-through datasources.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@buggtb buggtb added the security Created by Hive for agent-filed issue provenance label Nov 12, 2026
@github-actions github-actions Bot added risk/high Change risk tier: high (see docs/risk-tiers.md) area/service area/web docs labels Nov 12, 2026
@github-actions

Copy link
Copy Markdown

Semantic model diff

Semantic model diff

No model changes and no broken references.

saiku#1434 · reproduce locally with saiku model diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/service area/web docs risk/high Change risk tier: high (see docs/risk-tiers.md) security Created by Hive for agent-filed issue provenance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[security] Plaintext login password is cached in SessionService.sessionHolder for the life of the JVM and returned by getAllSessionObjects()

1 participant