fix(agents): warn when AgentTool config_path escapes agent base directory#1218
Conversation
|
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. |
|
I have read the CLA Documents and I hereby sign the CLA. |
4421e80 to
6e306c8
Compare
|
Hi @adilburaksen, thank you for your contribution! We appreciate you taking the time to submit this pull request. Could you please include the corresponding unit tests to verify your changes? |
|
Thanks for the review! I've added unit tests in |
|
Thank you for your response. please ensure your PR consists of a single commit. Could you please change your commits accordingly? |
f077057 to
f10eceb
Compare
|
Done — squashed into a single commit ( |
|
Thank you for the updates @adilburaksen. Currently this PR is under review by our team, we will keep you posted if any additional information is required. thank you. |
|
@sherryfox, Could you please review this PR. |
|
Gentle follow-up on this one. It's been about two weeks since it went into team review (Jun 3, routed to @sherryfox) — CI is green, CLA is signed, and it's squashed to a single commit. It's a small, self-contained path-traversal fix in |
|
Gentle ping for review. This is the Java side of the AgentTool |
|
Thank you for your response @adilburaksen . Could you please ensure your PR consists of a single commit? |
246195b to
644299f
Compare
|
Done — squashed to a single commit (644299f). It rebases the |
|
Hello @adilburaksen, after internal discussion we decided we cannot move forward with provided implementation, since it is a breaking change and could break tools that already operate using absolute paths or Could you bring back the previous functionality and add logging when path outside the agent base directory is detected? logger.error(
"AgentTool config_path '{}' accesses a path outside the agent base directory; this"
+ " behavior is deprecated and will be disallowed in a future release.",
configPath);We will proceed with your initial implementation in the next major release. Thank you for your contribution! |
644299f to
14aa069
Compare
|
Thanks @MiloszSobczyk, that makes sense. I've reworked the PR accordingly:
logger.error(
"AgentTool config_path '{}' accesses a path outside the agent base directory; this"
+ " behavior is deprecated and will be disallowed in a future release.",
configPath);
Still a single commit ( |
|
@adilburaksen Thanks for the change. You are right in saying that |
…tory Preserve the existing behavior of resolving absolute and relative (including `..`) AgentTool config_path values, but log a deprecation warning when the resolved path escapes the agent's base directory. This keeps backward compatibility for tools that rely on absolute or parent-relative paths while surfacing the risky access pattern ahead of disallowing it in a future release.
14aa069 to
7a4113e
Compare
|
Done — switched the log to |
@adilburaksen Could you update the description for the PR? |
|
Done — updated the title and description to reflect the current |
Summary
resolveSubAgentFromConfigPathinConfigAgentUtils.javaresolves a sub-agentconfig_pathfrom an agent YAML. Absolute paths and relative paths containing..areresolved as-is, so a
config_pathcan point outside the agent's base directory without anysignal that this is happening.
Per maintainer guidance, blocking these paths outright is a breaking change (existing tools
legitimately rely on absolute / parent-relative
config_pathvalues), so this PR keeps thecurrent behavior and adds an observable warning ahead of stricter enforcement in a future
major release.
Change
Preserve backward-compatible resolution — absolute
config_pathvalues and relativepaths containing
..are still honored.Log a
WARNdeprecation notice when the resolved path escapes the agent's basedirectory:
Tests
ConfigAgentUtilsTest(50/50 passing):config_pathstill resolves successfully (backward compatibility).config_pathwith..that escapes the base directory still resolvessuccessfully and triggers the deprecation warning.
..paths continue to resolve.Related
Same code path exists in
adk-python(google/adk-python#5826) andadk-go.