Uh oh!
There was an error while loading. Please reload this page.
fix: keep local environment file access in workspace - #5870
Conversation
04a49ff to
34870c2Comparerohityan
commented
May 27, 2026
Hi @he-yufeng , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Your PR has been received by the team and is currently under review. We will provide feedback as soon as we have an update to share. |
rohityan
commented
May 27, 2026
Hi @wyf7107 , can you please review this. |
Hi @he-yufeng and team, just verified that the fix corrects successfully the path traversal |
he-yufeng
commented
Jun 12, 2026
Gentle ping on this path-boundary fix. The branch is green, and #5869 verified the path traversal behavior after the patch. The change stays limited to keeping local environment file access inside the workspace root. Happy to make any naming or API-shape adjustment if maintainers prefer a different boundary helper. |
34870c2 to
3f2af35Comparehe-yufeng
commented
Jun 12, 2026
Rebased onto the current upstream/main and resolved the LocalEnvironment path-resolution conflict. The conflict was caused by upstream changing the helper to return Validation:
Current head: |
931452c to
29d160bComparehe-yufeng
commented
Jun 12, 2026
Rebased this on current
All passed locally. |
1d61969 to
77f9a9bComparee5c32d2 to
3c3cdd3Compare3c3cdd3 to
f08eadcCompareer3b07
commented
Jun 30, 2026
Hi @GWeale@wyf7107 — gentle ping on #5870 (Fixes #5869). I re-tested today against google-adk 2.3.0 on PyPI and current main: the path traversal behavior described in #5869 is still reproducible. I also confirmed the fix on this branch blocks the PoC as expected. Whenever there is an update on review timing, I am happy to help re-test or provide any additional details. Thank you for your time. |
wuliang229
commented
Jul 13, 2026
Merged in commit f41bc79 |
Backport of the `_local_environment.py` / `test_local_environment.py` portion of the following commit from `main`, released in v2.5.0: f41bc79 (squashed copybara commit; upstream PR google#5870, fixesgoogle#5869) Only the two files above are taken from that commit -- the rest of it is unrelated (a2a sample, PR-triage agent, transfer_to_agent_tool). Adapted rather than cherry-picked directly: on `main` `_resolve_path` returns a `Path`, while on v1 it returns `str` and `_sync_read` / `_sync_write` take `str`. The containment check is the same; the v1 return type is preserved to keep the change minimal. `_resolve_path` returned absolute paths verbatim: if os.path.isabs(path): return path so `working_dir` was advisory only, and `read_file` / `write_file` -- and therefore the ReadFile, WriteFile and EditFile tools -- could reach any path the process could access. Paths are now resolved against `working_dir` and rejected with a `ValueError` if they escape it. Absolute paths that stay inside `working_dir` keep working.
Backport of the `_local_environment.py` / `test_local_environment.py` portion of the following commit from `main`, released in v2.5.0: f41bc79 (squashed copybara commit; upstream PR google#5870, fixesgoogle#5869) Only the two files above are taken from that commit -- the rest of it is unrelated (a2a sample, PR-triage agent, transfer_to_agent_tool). Adapted rather than cherry-picked directly: on `main` `_resolve_path` returns a `Path`, while on v1 it returns `str` and `_sync_read` / `_sync_write` take `str`. The containment check is the same; the v1 return type is preserved to keep the change minimal. `_resolve_path` returned absolute paths verbatim: if os.path.isabs(path): return path so `working_dir` was advisory only, and `read_file` / `write_file` -- and therefore the ReadFile, WriteFile and EditFile tools -- could reach any path the process could access. Paths are now resolved against `working_dir` and rejected with a `ValueError` if they escape it. Absolute paths that stay inside `working_dir` keep working.
Fixes#5869
Summary
working_dirworking_dirworkingTests
python -m pytest tests\unittests\tools\test_local_environment.py -q -p no:cacheprovider --basetemp .tmp\pytestpython -m ruff check src\google\adk\environment\_local_environment.py tests\unittests\tools\test_local_environment.pypython -m pyink --check src\google\adk\environment\_local_environment.py tests\unittests\tools\test_local_environment.pypython -m py_compile src\google\adk\environment\_local_environment.py tests\unittests\tools\test_local_environment.pygit diff --check