Enforce session ownership in VertexAiSessionService.listEvents - #1435
Open
prasanna8585 wants to merge 1 commit into
Open
Enforce session ownership in VertexAiSessionService.listEvents#1435prasanna8585 wants to merge 1 commit into
prasanna8585 wants to merge 1 commit into
Conversation
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.
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.
Summary
Commit d1b1d92 (#1323) added an ownership check to
getSessionanddeleteSession- fetch the session, compare the backend-reported owner to the caller'suserId, deny as not-found on mismatch. The same check was not applied tolistEvents.Impact
listEventsreturns a session's full event stream (conversation content, tool calls, state deltas) addressed solely bysessionId, 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'ssessionIdcan read that user's full conversation history vialistEvents- the same disclosure class d1b1d92 fixed forgetSession/deleteSession, left open here.listEventsis public API (BaseSessionServiceinterface), not an internal helper.Fix
listEventsnow fetches the session and applies the same ownership checkgetSession/deleteSessionalready use before returning events, denying as an empty response (not an error) on mismatch - consistent withgetSession's not-found-style denial rather thandeleteSession's exception-based one, sincelistEvents' existing contract already returns an empty response for a nonexistent/eventless session.Testing
Added
listEvents_wrongUser_returnsEmpty, mirroring the existinggetSession_wrongUser_returnsEmptytest 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; fullVertexAiSessionServiceTestsuite passes with no regressions.