Skip to content

fix(agents): prevent path traversal in AgentTool config_path resolution#5826

Open
adilburaksen wants to merge 1 commit into
google:mainfrom
adilburaksen:fix/config-path-traversal
Open

fix(agents): prevent path traversal in AgentTool config_path resolution#5826
adilburaksen wants to merge 1 commit into
google:mainfrom
adilburaksen:fix/config-path-traversal

Conversation

@adilburaksen
Copy link
Copy Markdown

Summary

resolve_agent_reference in config_agent_utils.py accepted absolute config_path values unconditionally and joined relative paths without any boundary validation. An attacker-controlled config_path field in an agent YAML could traverse outside the intended agent directory.

Vulnerable pattern (before):

if os.path.isabs(ref_config.config_path):
    return from_config(ref_config.config_path)   # absolute accepted
else:
    return from_config(os.path.join(agent_dir, ref_config.config_path))  # no ".." check

PoC config:

tools:
  - tool_class: AgentTool
    args:
      agent:
        config_path: "../../../../../../etc/passwd"

This causes open("/etc/passwd", "r") server-side. A FileNotFoundError vs ValidationError difference also leaks path existence.

Fix

  • Reject absolute config_path values with ValueError
  • Normalize the joined path and verify it stays within the parent agent directory before calling from_config

Related

Same vulnerability exists in adk-java (PR: google/adk-java#...) and adk-go (PR: google/adk-go#...) — fix pattern is identical.

Note: This is distinct from the resolve_code_reference RCE (different function, different field, file-read impact vs code execution).

@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 23, 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
Copy link
Copy Markdown
Collaborator

adk-bot commented May 23, 2026

Response from ADK Triaging Agent

Hello @adilburaksen, thank you for creating this PR!

We really appreciate your contribution to fixing this path traversal vulnerability. However, it looks like this PR is currently not fully following our Contribution Guidelines.

Could you please address the following items:

  1. Sign the Contributor License Agreement (CLA): It seems the CLA check has failed. Please visit https://cla.developers.google.com/ to sign the Google CLA.
  2. Add Unit Tests: Since this is a bug fix, please add or update unit tests under tests/unittests/ (using pytest) to verify this new behavior and prevent future regressions.
  3. Provide a Testing Plan: Please include a testing plan section in your PR description detailing how you verified these changes.
  4. Provide Logs/E2E Verification: Please provide logs or command outputs demonstrating the fix working as expected (e.g. showing the ValueError raised during path traversal attempts).

Once these items are addressed, it will be much easier and faster for our reviewers to evaluate your PR. Thank you!

@adilburaksen
Copy link
Copy Markdown
Author

I have read the CLA Documents and I hereby sign the CLA.

Absolute config_path values were accepted unconditionally, and relative
paths were joined without boundary validation, allowing traversal outside
the agent directory via "../../../etc/passwd" style inputs.

Fix: reject absolute paths; for relative paths, verify the normalized
result stays within the parent agent's directory before loading.
@adilburaksen adilburaksen force-pushed the fix/config-path-traversal branch from c04372a to 1274b09 Compare May 23, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants