You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: validate module paths in YAML config to prevent arbitrary code execution - #6117
Fix for #5822 - Add module path validation to resolve_code_reference(), resolve_fully_qualified_name(), and _resolve_agent_code_reference() in config_agent_utils.py to prevent importing dangerous stdlib modules via YAML agent config.
Problem
These functions call importlib.import_module() with no validation on the module path. A malicious YAML config can specify any Python module path, causing the ADK to import os, subprocess, sys, or any stdlib module. Combined with attribute access via getattr(), this enables arbitrary code execution.
The resolve_code_reference(), resolve_fully_qualified_name(), and _resolve_agent_code_reference() functions call importlib.import_module() without validating the module path. A malicious YAML agent config can import dangerous stdlib modules (os, subprocess, sys, pickle, etc.).
Fix: Added _validate_module_path() with a blocklist of 25 dangerous modules, regex format validation, and dunder segment rejection. 15 unit tests included.
rohityan
added
agent config
[Component] This issue is related to the Agent Config interface and implementation
request clarification
[Status] The maintainer need clarification or more information from the author
labels
Jun 17, 2026
Hi @Ashutosh0x , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Please fix formatting errors before we can proceed with a review.
adk-bot
added
the
core
[Component] This issue is related to the core interface and implementation
label
Jun 24, 2026
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
agent config[Component] This issue is related to the Agent Config interface and implementationcore[Component] This issue is related to the core interface and implementationrequest clarification[Status] The maintainer need clarification or more information from the author
4 participants
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.
Summary
Fix for #5822 - Add module path validation to
resolve_code_reference(),resolve_fully_qualified_name(), and_resolve_agent_code_reference()inconfig_agent_utils.pyto prevent importing dangerous stdlib modules via YAML agent config.Problem
These functions call
importlib.import_module()with no validation on the module path. A malicious YAML config can specify any Python module path, causing the ADK to importos,subprocess,sys, or any stdlib module. Combined with attribute access viagetattr(), this enables arbitrary code execution.Example malicious YAML:
`yaml
tools:
name: os.system
`
Fix
Added
_validate_module_path()that enforces:__builtins__and similar dunder segmentsCalled in all 3 code resolution entry points:
resolve_fully_qualified_name()_resolve_agent_code_reference()resolve_code_reference()Testing
Added
tests/unittests/agents/test_config_module_validation.pywith 15 tests:�ash pytest tests/unittests/agents/test_config_module_validation.py -vFixes #5822