Skip to content

fix: validate user_id and session_id against path traversal in FileArtifactService#5206

Open
enjoykumawat wants to merge 2 commits intogoogle:mainfrom
enjoykumawat:fix/file-artifact-path-traversal
Open

fix: validate user_id and session_id against path traversal in FileArtifactService#5206
enjoykumawat wants to merge 2 commits intogoogle:mainfrom
enjoykumawat:fix/file-artifact-path-traversal

Conversation

@enjoykumawat
Copy link
Copy Markdown

Summary

  • Add _validate_path_segment() to reject path separators and traversal sequences in user_id and session_id
  • Only FileArtifactService affected — GCS and InMemory use string keys

Root Cause

_resolve_scoped_artifact_path validates filenames but user_id/session_id were used directly in Path() construction. A user_id containing ../ could escape root_dir.

Test Plan

  • Tests proving ../ in user_id/session_id now raises ValueError
  • Normal values still work

Fixes #5110

@adk-bot adk-bot added the services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc label Apr 8, 2026
@rohityan rohityan self-assigned this Apr 9, 2026
…tifactService

FileArtifactService validated filenames for path traversal but used
user_id and session_id directly in Path() construction without
validation. A user_id or session_id containing ../ segments could
escape the root_dir. Add _validate_path_segment() to reject path
separators (/, \) and traversal sequences (..) in these parameters.

Fixes google#5110
@enjoykumawat enjoykumawat force-pushed the fix/file-artifact-path-traversal branch from 9957c52 to cd9cd6b Compare April 9, 2026 07:43
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.

FileArtifactService: user_id and session_id not validated for path traversal

3 participants