Repository navigation
Conversation
os.path.isabs is platform-dependent: on Windows a root-relative path such as /etc/passwd has no drive and is not absolute, so the AgentRefConfig guard let it through to the traversal check, which reports a different error than the documented one (and an unhandled commonpath error across drives). Reject config_path rooted under either platform's spelling so the guard behaves the same everywhere.
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to Issue or Description of Change
No issue exists for this yet; the change is described below following the issue
template structure.
Problem:
AgentRefConfig.config_pathlets a YAML agent config reference another agent'sconfig file.
resolve_agent_referenceinsrc/google/adk/agents/config_agent_utils.pyrejects absolute paths with:os.path.isabsis platform-dependent. On Windows, a root-relative path thathas a root but no drive — for example
/etc/passwdor\etc\passwd— is notabsolute (
ntpath.isabs('/etc/passwd')isFalse), so the guard does not fire.The path then falls through to the traversal check, which either reports the
wrong error ("Path traversal detected ... resolves outside the agent directory"
instead of the intended "Absolute paths are not allowed ...") or, when the agent
directory sits on a different drive than the resolved root, an unhandled
ValueError: Paths don't have the same drivefromos.path.commonpath.The repo's own unit test
tests/unittests/agents/test_agent_config.py::test_resolve_agent_reference_blocks_absolute_pathasserts the intended cross-platform behavior and is not skipped on any platform,
but it fails on Windows for exactly this reason (CI only runs on Linux, so the
failure is invisible there).
Solution:
Treat a
config_pathrooted under either platform's spelling as absolute, sothe guard behaves identically everywhere:
This matches the platform-independent path checks the codebase already uses
elsewhere (e.g.
skills/_utils.pyandskill_toolset.pycombinePurePosixPath/PureWindowsPathroot checks). Behavior on POSIX is unchanged;on Windows, root-relative paths now raise the documented error.
Testing Plan
Unit Tests:
I have added or updated unit tests for my change.
All unit tests pass locally.
Added
test_resolve_agent_reference_blocks_root_relative_path, which checksboth
/etc/passwdand\etc\passwdraise the documented error.Red→green on Windows 11, Python 3.13.9:
pytest tests/unittests/agents/test_agent_config.py→1 failed (
test_resolve_agent_reference_blocks_absolute_path:expected "Absolute paths are not allowed in AgentRefConfig config_path",
got "Path traversal detected ..."), 194 passed.
regression test).
pytest tests/unittests/agents→ 972 passed, 1 xfailed.ruff checkandpyink --check(repo pins: ruff 0.15.17, pyink 25.12) passon both changed files.
Manual End-to-End (E2E) Tests:
Not applicable beyond the above: the change only alters which
ValueErrormessage a rejected reference raises, and it is exercised directly by the unit
tests with a mocked
from_config(no network or model calls involved).Checklist
Additional context
mainat766275863d1e80489344f0fbe5b4bfa3b933a9a9.resolve_agent_reference,AgentRefConfig, orisabs(GitHub search, 2026-11-04). PR fix: Port agent-config code-reference and config_path validation to v1 #6790 ("Portagent-config code-reference and config_path validation to v1") was merged
against the v1 branch and does not touch this guard on
main.AI assistance
This contribution was prepared with AI assistance (code search, reproduction,
and patch drafting). The final diff is two files: a one-condition change in
resolve_agent_referenceplus a regression test; all validation commands andresults above were run locally against the repository's own test suite.