T08 · Insecure Dependencies
- Location
scripts/extract_text.py:15- Finding
Automatic Installation of Unpinned System and Python Dependencies
- Content
View full analysis
Vulnerability Details
File Location:
scripts/extract_text.py, lines 15–24
Vulnerability Type: Automatic installation of unpinned third-party dependencies
Risk Level: MediumVulnerable Code
python def ensure_deps(): try: import pytesseract pytesseract.get_tesseract_version() return pytesseract except Exception: print("Installing tesseract-ocr...") subprocess.run(["apt-get","install","-y","-q", "tesseract-ocr","tesseract-ocr-chi-sim"], check=True) subprocess.run([sys.executable,"-m","pip","install","pytesseract", "--break-system-packages","-q"], check=True) import pytesseract return pytesseractThe same unsafe installation approach is also documented in
SKILL.md, lines 25–26 and 484–498:bash npm install -g pptxgenjs pip install Pillow numpy pytesseract --break-system-packages -qpython subprocess.run(["apt-get","install","-y","-q", "tesseract-ocr","tesseract-ocr-chi-sim"], check=True) subprocess.run([sys.executable,"-m","pip","install","pytesseract", "--break-system-packages","-q"], check=True)Technical Analysis
The OCR helper automatically invokes APT and pip when any exception occurs while importing
pytesseractor querying the Tesseract version. The installed packages are not pinned to exact versions, verified with hashes, or resolved through a lockfile. Consequently, the effective code installed at runtime may change independently of the audited project.The
--break-system-packagesoption bypasses Python environment protections and permits modification of the host-managed Python environment. Likewise, the documented global npm installation modifies a shared package location.The broad
except Exceptionclause further expands the trigger condition. An unrelated runtime or configuration error—not merely a missing dependency—can initiate package-manag ...[truncated 1682 chars]- Remediation
View remediation
Remediation Suggestions
- Remove automatic package installation from
ensure_deps()and fail safely with a clear dependency error. - Provision dependencies before runtime in an isolated virtual environment or container.
- Pin exact APT, pip, and npm dependency versions through reproducible build configuration.
- Use a hash-locked requirements file, such as
pip install --require-hashes -r requirements.txt. - Add and enforce an npm lockfile; avoid global npm installation.
- Do not use
--break-system-packages. Install Python dependencies into a dedicated virtual environment. - Catch only expected errors such as
ImportErrororModuleNotFoundError; report Tesseract configuration failures separately instead of initiating installation. - Use trusted, explicitly configured repositories and verify package provenance where supported.
- Build dependencies with minimal privileges, then run OCR as an unprivileged user in a restricted environment.
- Update
SKILL.mdso its installation instructions follow the same pinned and isolated dependency process.
- Remove automatic package installation from
