T08 · Insecure Dependencies
Error
- Location
- scripts/run.py:180
- Finding
- Execution of an Unverified Python Module Outside the Audited Package<![CDATA[ ## Vulnerability Details **File Location**: `scripts/run.py:180-187` **Vulnerability Type**: Untrusted external dependency execution **Risk Level**: High ### Vulnerable Code ```python _shared_dir = Path(__file__).resolve().parent.parents[3] / "_shared" / "doc-preprocess" / "scripts" if not _shared_dir.exists(): print(f"ERROR: 无法读取输入文件,本地预处理失败且 _shared/doc-preprocess 不可用。原因:{exc}", file=sys.stderr) return 1 import importlib.util as _iu _spec = _iu.spec_from_file_location("_shared_preprocess", _shared_dir / "preprocess.py") _sp = _iu.module_from_spec(_spec) _spec.loader.exec_module(_sp) ``` ### Technical Analysis When local preprocessing raises `PreprocessError`, the program searches for a Python module outside the skill package and executes it through `exec_module`. The referenced `_shared/doc-preprocess/scripts/preprocess.py` file is not included in the audited project, so its contents, version, integrity, and provenance cannot be verified as part of this skill. `exec_module` executes all top-level statements in the selected file with the same operating-system identity and permissions as the skill process. The implementation does not verify a cryptographic digest, package signature, trusted ownership, file permissions, or an immutable version before execution. The fallback therefore creates an unsafe supply-chain and local trust boundary: control over the resolved shared module is equivalent to control over the skill process. ### Attack Path 1. An attacker gains the ability to create or modify the external `_shared/doc-preprocess/scripts/preprocess.py` file at the path derived by `parents[3]`. 2. The attacker adds arbitrary Python statements to the module's top-level scope. 3. A user invokes the skill with an input that causes the bundled preprocessor to raise `PreprocessError`, such as an input requiring unavailable parsing support or one that fails local extraction. 4. The fallback locates the attacker-controlled shared module. 5. `e ...[truncated 766 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the path-based fallback and use only the preprocessing implementation shipped inside the audited package. 2. If preprocessing must be shared, distribute it as a version-pinned package from a trusted registry or immutable internal artifact store. 3. Verify the dependency's cryptographic digest or signature before loading it. 4. Refuse to execute modules from writable shared directories. 5. Validate file ownership and permissions where local loading is unavoidable. 6. Import only through a controlled package environment rather than `spec_from_file_location` and `exec_module`. 7. Run document parsing in a sandbox with minimal filesystem access, no unnecessary credentials, constrained network access, and resource limits. 8. Include the complete shared component in future security reviews and dependency inventories. ]]>
