You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Validate path segments in GcsArtifactService and InMemoryArtifactService to prevent cross-user artifact access
InMemoryArtifactService and GcsArtifactService currently construct GCS/In-Memory
paths by directly interpolating user-supplied identifiers (user_id, app_name,
and session_id) without validation. A malicious identifier containing path
separators or traversal segments (e.g., ../other-user) could escape the
intended scope and allow cross-user artifact access.
This patch brings GcsArtifactService, InMemoryArtifactService, and FileArtifactService
to parity and unifies their validation logic:
- Refactored all path segment validation logic into a shared helper in `artifact_util.py`.
- Validate `user_id`, `app_name`, and `session_id` in `GcsArtifactService`, `InMemoryArtifactService`, and `FileArtifactService` using the shared helper.
- Consolidated path traversal tests into a parameterized suite in `test_artifact_service.py` and `test_artifact_util.py`.
Closes#6115Closes#6116
Co-authored-by: Jason Zhang <jasoncz@google.com>
PiperOrigin-RevId: 943976800
0 commit comments