T08 · Insecure Dependencies
Warning
- Location
- scripts/memory_manager.py:165
- Finding
- Unpinned Third-Party Dependency Installation Guidance<![CDATA[ ## Vulnerability Details **File Location**: `scripts/memory_manager.py:165-169` and `scripts/memory_manager.py:181-185` **Vulnerability Type**: Unpinned dependency and software supply-chain exposure **Risk Level**: Medium ### Vulnerable Code ```python def init_vector_store(): """初始化向量存储""" try: import chromadb from chromadb.config import Settings except ImportError: print("✗ 需要安装 chromadb: pip install chromadb") return False ``` The same installation guidance is repeated when adding long-term memory: ```python def add_long_term_memory(content: str, metadata: dict = None): """添加长期记忆(向量存储)""" try: import chromadb from chromadb.config import Settings except ImportError: print("✗ 需要安装 chromadb: pip install chromadb") return False ``` ### Technical Analysis When ChromaDB is unavailable, the application instructs users to execute `pip install chromadb` without specifying an audited version, integrity hash, or trusted package index. The code does not automatically execute this command, but its official installation guidance encourages resolution and installation of whichever package version the configured Python package index currently serves. This creates a non-reproducible dependency chain and exposes users to compromised future releases, unsafe transitive dependency changes, package-index substitution, and malicious mirror configuration. Python packages may execute package-controlled build logic during installation and arbitrary module-level code when imported. ### Attack Path 1. An attacker compromises a future `chromadb` release, one of its transitive dependencies, or a package index/mirror used by the victim. 2. The victim runs the memory manager without ChromaDB installed. 3. The script displays the unpinned `pip install chromadb` instruction. 4. The victim follows the instruction in an affected Python environment. 5. Pip resolves the attacker-controlled ...[truncated 677 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Provide a reviewed dependency manifest, such as a locked `requirements.txt` or lockfile, containing an explicitly approved ChromaDB version. 2. Pin all transitive dependencies and use cryptographic hashes where the package-management workflow supports them. 3. Replace the generic instruction with a command that installs from the reviewed manifest, for example: ```bash python3 -m pip install --require-hashes -r requirements.txt ``` 4. Document the approved package index and prevent unintended fallback to untrusted mirrors. 5. Run dependency vulnerability and provenance checks during CI. 6. Install dependencies in an isolated virtual environment with least privilege rather than a system-wide or privileged Python environment. ]]>
