Skip to content

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

Closed
enjoykumawat wants to merge 3 commits into
google:mainfrom
enjoykumawat:fix/file-artifact-path-traversal
Closed

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

Conversation

@enjoykumawat

Copy link
Copy Markdown
Contributor

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
@rohityan rohityan added the request clarification [Status] The maintainer need clarification or more information from the author label Apr 13, 2026
@rohityan

Copy link
Copy Markdown
Collaborator

Hi @enjoykumawat , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Please fix failing mypy-diff tests before we can proceed with a review.

@rohityan

Copy link
Copy Markdown
Collaborator

Hi @enjoykumawat , closing this since it has been fixed in this commit. cbcb5e6

@rohityan rohityan closed this Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

request clarification [Status] The maintainer need clarification or more information from the author 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