Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/google/adk/skills/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""Utility functions for Agent Skills."""

from __future__ import annotations

import os
import logging
import pathlib
from typing import Union
Expand Down Expand Up @@ -407,10 +407,17 @@ def _load_files_in_dir(subdir: str) -> Dict[str, Union[str, bytes]]:
result = {}

for blob in blobs:
relative_path = blob.name[len(prefix) :]
relative_path = blob.name[len(prefix):]
if not relative_path:
continue

# Prevent path traversal via malicious GCS blob names
normalized = os.path.normpath(relative_path)
if normalized.startswith('..') or os.path.isabs(normalized):
raise ValueError(
f"Unsafe path in skill resource: {relative_path!r}"
)

try:
result[relative_path] = blob.download_as_text()
except UnicodeDecodeError:
Expand Down