Skip to content

Enforce session ownership in VertexAiSessionService.listEvents - #1435

Open
prasanna8585 wants to merge 1 commit into
google:mainfrom
prasanna8585:fix/listevents-ownership-check
Open

Enforce session ownership in VertexAiSessionService.listEvents#1435
prasanna8585 wants to merge 1 commit into
google:mainfrom
prasanna8585:fix/listevents-ownership-check

Conversation

@prasanna8585

Copy link
Copy Markdown

Summary

Commit d1b1d92 (#1323) added an ownership check to getSession and deleteSession - fetch the session, compare the backend-reported owner to the caller's userId, deny as not-found on mismatch. The same check was not applied to listEvents.

Impact

listEvents returns a session's full event stream (conversation content, tool calls, state deltas) addressed solely by sessionId, with no ownership check. The Vertex backend session-events sub-resource does not enforce per-caller ownership on its own (per the existing comments on the getSession/deleteSession checks in this same file), so any authenticated caller who knows or guesses another user's sessionId can read that user's full conversation history via listEvents - the same disclosure class d1b1d92 fixed for getSession/deleteSession, left open here. listEvents is public API (BaseSessionService interface), not an internal helper.

Fix

listEvents now fetches the session and applies the same ownership check getSession/deleteSession already use before returning events, denying as an empty response (not an error) on mismatch - consistent with getSession's not-found-style denial rather than deleteSession's exception-based one, since listEvents' existing contract already returns an empty response for a nonexistent/eventless session.

Testing

Added listEvents_wrongUser_returnsEmpty, mirroring the existing getSession_wrongUser_returnsEmpty test in the same file. Verified locally: the new test fails against the unfixed code (confirming it genuinely exercises the gap) and passes with the fix; full VertexAiSessionServiceTest suite passes with no regressions.

Commit d1b1d92 added an ownership check to getSession and deleteSession
(compare the backend-reported session owner to the caller's userId,
deny as not-found on mismatch), but the same check was not applied to
listEvents.

listEvents returns a session's full event stream (conversation
content, tool calls, state deltas) addressed solely by sessionId. The
Vertex backend session-events sub-resource does not enforce per-caller
ownership on its own (per the existing comments on the getSession/
deleteSession checks), so without a client-side check any authenticated
caller who knows or guesses another user's sessionId can read that
user's full conversation history via listEvents, the same disclosure
class d1b1d92 fixed for getSession/deleteSession, left open here.

Fixes listEvents to fetch the session and apply the same ownership
check getSession/deleteSession already use before returning events,
denying as empty (not an error) on mismatch, consistent with
getSession's not-found-style denial.

Adds a regression test (listEvents_wrongUser_returnsEmpty) mirroring
the existing getSession_wrongUser_returnsEmpty test.
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