T08 · Insecure Dependencies
- Location
scripts/markdown_to_docx.py:18- Finding
Unpinned Third-Party Dependency Installation Guidance
- Content
View full analysis
Vulnerability Details
File Location:
scripts/markdown_to_docx.py, lines 18–23
Vulnerability Type: Unpinned third-party dependency and insufficient supply-chain controls
Risk Level: MediumVulnerable Code
python try: from docx import Document from docx.shared import Pt, Cm, RGBColor from docx.enum.text import WD_ALIGN_PARAGRAPH from docx.oxml.ns import qn except ImportError: print("缺少依赖:python-docx") print("请运行:pip install python-docx") sys.exit(1)Technical Analysis
If the
docxmodule is unavailable, the script instructs the user to installpython-docxdirectly from the package index without specifying a reviewed version, verifying package hashes, using a lockfile, or requiring an isolated environment.The package name is consistent with the legitimate dependency, and the script neither performs the installation automatically nor specifies a suspicious package index. Nevertheless, following this instruction resolves the latest available package and its transitive dependencies at installation time. This makes installation non-reproducible and exposes users to future package compromise, malicious dependency substitution, or incompatible releases.
Python packages may run code during installation, and imported packages execute module-level code at runtime. A compromised package or dependency could therefore execute with the permissions of the user performing the installation or running the converter.
Attack Path
- A user runs
scripts/markdown_to_docx.pyon a system wherepython-docxis not installed. - The import fails, and the script displays the instruction
pip install python-docx. - The user follows the instruction without a pinned version, verified hashes, or a trusted lockfile.
- The package manager retrieves the currently resolved package and transitive dependencies from its configured index.
- If a future release, transitiv ...[truncated 822 chars]
- A user runs
- Remediation
View remediation
Remediation Suggestions
-
Add a dependency manifest containing a reviewed, exact
python-docxversion. -
Generate and verify cryptographic hashes for the package and all transitive dependencies.
-
Install dependencies with hash enforcement, for example:
bash python -m pip install --require-hashes -r requirements.txt -
Recommend installation inside a dedicated virtual environment rather than the system Python environment.
-
Use an organization-controlled package mirror or explicitly documented trusted index where appropriate.
-
Add automated dependency vulnerability and integrity scanning to the release process.
-
Replace the unpinned installation message with instructions that reference the reviewed dependency file, such as:
python except ImportError: print("Missing dependency. Install reviewed packages in an isolated environment:") print("python -m pip install --require-hashes -r requirements.txt") sys.exit(1) -
Regularly review and deliberately update pinned versions and hashes rather than allowing implicit upgrades.
-
