T09 · Insecure Skill Coding Practices
- Location
scripts/env_check.py:93- Finding
Dependency inspection imports and executes modules from user-supplied source
- Content
View full analysis
RequirementStatus: import_name = PACKAGE_TO_IMPORT.get(package.lower(), package) try: mod = importlib.import_module(import_name) version = getattr(mod, "__version__", None) ``` ### Technical Analysis `check_requirements(script_path=...)` statically extracts import names from a potentially untrusted Python file, but `_check_package()` then calls `importlib.import_module()` for every extracted name. Importing a Python module is an executable operation: its module-level statements and package initialization files are run immediately. Consequently, a function presented as a dependency availability check can execute arbitrary code from a local module, a malicious package already on `sys.path`, or a package whose initialization has unintended side effects. This also conflicts with the recommendation in `SKILL.md` to use `check_requirements(script_path)` to inspect an untrusted script before running it. Although the target script itself is not executed, modules named by that script may be executed. ### Attack Path 1. An attacker supplies a Python file containing an import such as: ```python import attacker_module ``` 2. The attacker arranges for `attacker_module.py` or an equivalent package to be ...[truncated 742 chars]- Remediation
View remediation
