Skip to content

fix(sessions): validate session_id and enforce ownership in delete_session#5577

Closed
nicola-pesavento wants to merge 1 commit intogoogle:mainfrom
nicola-pesavento:fix/vertex-ai-session-id-validation
Closed

fix(sessions): validate session_id and enforce ownership in delete_session#5577
nicola-pesavento wants to merge 1 commit intogoogle:mainfrom
nicola-pesavento:fix/vertex-ai-session-id-validation

Conversation

@nicola-pesavento
Copy link
Copy Markdown

@nicola-pesavento nicola-pesavento commented May 3, 2026

No description provided.

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.
@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 3, 2026

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.

@adk-bot adk-bot added the services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc label May 3, 2026
@adk-bot
Copy link
Copy Markdown
Collaborator

adk-bot commented May 3, 2026

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!

@nicola-pesavento nicola-pesavento deleted the fix/vertex-ai-session-id-validation branch May 3, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants