fix(firestore): honor appName in getSession/deleteSession/listEvents#1361
Merged
copybara-service[bot] merged 1 commit intoJul 22, 2026
Merged
Conversation
Contributor
|
Hi @petrmarinec, thank you for your contribution! We appreciate you taking the time to submit this pull request. To proceed with the review, could you please address the following,
|
petrmarinec
force-pushed
the
fix/firestore-session-appname-scope
branch
from
July 20, 2026 10:00
4d0a80a to
87471cc
Compare
…sion/listEvents
FirestoreSessionService stores each session at /{root}/{userId}/sessions/{sessionId},
so the document is keyed only by (userId, sessionId). getSession, deleteSession, and
listEvents fetched the document by (userId, sessionId) and never checked the stored
appName against the requested one, so a caller could read, list the events of, or
delete another application's session for the same user by passing any appName.
listSessions already scopes by appName (whereEqualTo(APP_NAME_KEY, appName)).
Add the same appName check to getSession, deleteSession, and listEvents, treating a
mismatch as "session not found", and add unit tests covering the appName-mismatch
cases for all three methods.
petrmarinec
force-pushed
the
fix/firestore-session-appname-scope
branch
from
July 20, 2026 10:03
87471cc to
a370034
Compare
Contributor
Author
|
Thanks for the review! I've addressed all three points:
|
Contributor
|
@petrmarinec, thank you for addressing those points and providing the updated tests. Your changes are now under review by our team and we will keep you posted if we require any further updates. Thanks you. |
kvmilos
force-pushed
the
fix/firestore-session-appname-scope
branch
from
July 21, 2026 09:09
c6654f4 to
a370034
Compare
kvmilos
approved these changes
Jul 21, 2026
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.
Description of Change
FirestoreSessionServicestores each session at/{root}/{userId}/sessions/{sessionId}— keyed only by(userId, sessionId).appNameis saved as a field (APP_NAME_KEY) but is not part of the key, and three methods fetch the document by(userId, sessionId)without checking it:getSession(appName, userId, sessionId, ...)— returns the document regardless ofappName.listEvents(appName, userId, sessionId)— checks only that the document exists.deleteSession(appName, userId, sessionId)— deletes regardless ofappName.listSessions(appName, userId)already scopes correctly withgetSessionsCollection(userId).whereEqualTo(APP_NAME_KEY, appName), so the omission in the other three is an oversight.Because
appNameis accepted but ignored, when several ADK applications share one Firestore for the same users, application B can read, list the events of, or delete application A's session by using A's session ID with anyappName— e.g.getSession("appB", U, S)returns app A's session. Sessionstatecan hold OAuth tokens (viaSessionStateCredentialService) and conversation history, so this is a cross-application read (confidentiality) and delete (integrity) issue.InMemorySessionServicekeys onappName -> userId -> sessionId, so this also brings the Firestore backend in line with the in-memory contract.This change adds the
appNamecheck togetSession,deleteSession, andlistEvents, treating a mismatch as "session not found", mirroringlistSessions.Testing Plan
Scope check only; matching
appNamebehaves exactly as before. Suggested regression test (Firestore emulator): create a session under(appA, U, S), then assertgetSession(appB, U, S)andlistEvents(appB, U, S)raiseSessionNotFoundExceptionanddeleteSession(appB, U, S)leaves it intact, while all three succeed forappA.