Skip to content

fix(configurable): prevent path traversal in AgentTool config_path resolution (#878) - #1277

Merged
wolo-lab merged 1 commit into
v1from
wolo/backport-878-path-traversal
Aug 10, 2026
Merged

fix(configurable): prevent path traversal in AgentTool config_path resolution (#878)#1277
wolo-lab merged 1 commit into
v1from
wolo/backport-878-path-traversal

Conversation

@wolo-lab

Copy link
Copy Markdown
Contributor

Problem

ResolveAgentReference accepts absolute refPath values unconditionally and joins
relative paths with filepath.Join without any boundary enforcement. An
attacker-controlled config_path in an agent YAML can therefore read any file the
server process can reach. v1 carries the identical resolution logic, so the
vulnerability is present here too.

Summary

Backports #878 from main.

  • Reject absolute refPath values.
  • After resolving, verify the cleaned path stays inside the parent agent's directory.

The same fix landed in adk-python (google/adk-python#5826) and adk-java
(google/adk-java#1218); the pattern is identical across the three SDKs.

…solution (#878)

fix(configurable): prevent path traversal in AgentTool config_path resolution

Reject absolute config_path values and verify that a relative one resolves
inside the referencing agent's directory, resolving symlinks where the paths
exist. Matches the hard rejection adk-python landed in 171ae9e; adk-java
(#1218) chose a warn-only deprecation instead.

BREAKING: an absolute config_path is no longer accepted.

---------

* fix(configurable): prevent path traversal in AgentTool config_path resolution

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; verify the resolved path stays within the
parent agent's directory using strings.HasPrefix after filepath.Clean.

* fix(configurable): compare absolute, symlink-resolved paths in the config_path containment check

The containment check for AgentTool config_path compared an absolute target
path against a parent directory that was only cleaned, not made absolute, so a
relative parentPath caused legitimate in-directory references to be rejected.
The comparison was also purely lexical, so a symlink inside the agent directory
could still resolve outside it and be loaded.

Make both sides absolute before comparing and resolve symlinks where the paths
exist, falling back to the lexical path when they do not so that a missing file
still reports as not found rather than as a traversal.

Add regression tests covering absolute paths, parent traversal, symlink escape,
references inside the agent directory, and a relative parent path.

---------

Co-authored-by: João Westerberg <westerberg@google.com>

(cherry picked from commit 604dd63)

@karolpiotrowicz karolpiotrowicz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change matches #878 exactly: after the cherry-pick, ResolveAgentReference is
byte-for-byte the same function as on main.

One thing to add before this lands. The commit message carries "BREAKING: an
absolute config_path is no longer accepted", but the PR description doesn't.
That distinction mattered less on main, where it shipped inside a major version;
on v1 it's a behavioral break in a minor release, and anyone currently passing an
absolute config_path starts getting an error on upgrade. Worth surfacing in the
description and in the v1.6.0 release notes.

The backport is clearly warranted — on current v1 the absolute-path case resolves
and loads the target, so /etc/passwd is read and parsed as agent YAML.

@wolo-lab
wolo-lab merged commit 68cb886 into v1 Aug 10, 2026
3 checks passed
@wolo-lab
wolo-lab deleted the wolo/backport-878-path-traversal branch August 10, 2026 12:24
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.

3 participants