fix(sessions): validate session_id and enforce ownership in delete_session#5577
Closed
nicola-pesavento wants to merge 1 commit intogoogle:mainfrom
Closed
fix(sessions): validate session_id and enforce ownership in delete_session#5577nicola-pesavento wants to merge 1 commit intogoogle:mainfrom
nicola-pesavento wants to merge 1 commit intogoogle:mainfrom
Conversation
VertexAiSessionService interpolated session_id directly into the Vertex AI
REST URL path with no validation, and delete_session ignored its user_id
parameter. This allowed two flaws when a backend forwarded a frontend-
supplied session_id to delete_session():
1. Path traversal via session_id (e.g. "..", "..?force=true",
"../../../datasets/<id>"): httpx resolves ../ before sending the
request, so the Vertex AI API receives a clean path pointing to a
sibling resource — including the parent reasoning engine itself.
2. Cross-user deletion (delete-IDOR): delete_session accepted user_id
but never used it, so any caller knowing a session_id could delete
a session belonging to another user.
This change adds:
- _validate_session_id(): strict regex (^[A-Za-z0-9_-]+$) applied at
every interpolation site (create_session, get_session, delete_session,
append_event). Matches the format of server-generated session IDs
and client-supplied UUIDs while rejecting '/', '..', '?', etc.
- delete_session: fetches the session first and verifies user_id
matches, mirroring the existing check in get_session.
Tests added for both fixes.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Collaborator
|
Response from ADK Triaging Agent Hello @nicola-pesavento, thank you for your contribution! Before we can merge this pull request, you'll need to sign a Contributor License Agreement (CLA). You can do so by following the instructions in the "cla/google" check at the bottom of the pull request. Thanks! |
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.
No description provided.