Repository navigation
Restrict builder YAML code references - #5293
petrmarinec wants to merge 2 commits into
Conversation
|
Hi @petrmarinec ,Thank you for your contribution! We appreciate you taking the time to submit this pull request. Can you please fix the mypy-diff errors. |
|
Hi, quick follow-up here: the earlier mypy-diff issue has been resolved on the current PR head, and the PR checks are green now. Happy to provide any additional detail if useful for review. |
|
Hi @xuanyang15 , can you please review this. |
|
@wyf7107 Could you please help take a look? |
7fc816e to
d313520
Compare
|
thanks for finding this, the hole was real and your writeup is what got it fixed. the restriction landed separately as _check_code_reference in cli/dev_server.py, released in 2.7.0 and in 1.39.1 on the v1 line. i re-ran your examples against it, all five return 400 and the safe references still save. closing since the builder code has moved out of fast_api.py. open a new issue if you see this happen again. |
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
The builder upload endpoint already blocks Python uploads and YAML
argskeys because uploaded YAML can cause Python code to be instantiated or invoked through agent configuration. However, the upload validator still allowed arbitrary dotted code references such asos.systemin tool, callback, sub-agentcode, and other CodeConfig fields. The YAML agent loader resolves those names withimportlib.import_module()andgetattr(), so a YAML-only builder upload could expose external callables as agent tools or callbacks.Solution:
Restrict builder-uploaded YAML code references to the app being edited, while preserving short ADK built-in tool names and built-in agent classes. The validator now rejects external dotted references such as
os.system, including the edge case where a stdlib app name likeoswould otherwise makeos.systemlook project-local.Testing Plan
Unit Tests:
Passed locally:
The broader FastAPI slice excludes two existing Windows CRLF response-body assertions and A2A tests, matching the known local Windows baseline unrelated to this change.
Manual End-to-End (E2E) Tests:
Not run. The affected builder upload validation path is covered by unit tests. I also validated the underlying pre-fix code path locally by loading a YAML config with an external callable tool reference and confirming that invoking the loaded tool executes in-process.
Checklist
Additional context
This change is scoped to the builder web upload endpoint. It does not change the general YAML agent config loader for local/trusted YAML files.