T08 · Insecure Dependencies
- Location
scripts/read_jd.py:22- Finding
Automatic Installation of an Unpinned Third-Party Dependency
- Content
View full analysis
Vulnerability Details
File Location:
scripts/read_jd.py, lines 22–32
Vulnerability Type: Supply-chain risk caused by automatic installation of an unpinned dependency
Risk Level: MediumVulnerable Code
python def _ensure_pdfmuse(): try: import pdfmuse # noqa: F401 return pdfmuse except ImportError: print("pdfmuse not found -- installing (one-time)...", file=sys.stderr) subprocess.run([sys.executable, "-m", "pip", "install", "-q", "pdfmuse"], check=True) import pdfmuse # noqa: F401 return pdfmuseThe dependency manifest also leaves the package unpinned:
text pdfmuseThis occurs at
requirements.txt, line 1.Technical Analysis
When a PDF or DOCX job description is processed and
pdfmuseis unavailable, the script automatically invokespipto retrieve and install the latest package selected by the configured Python package index. Neither the runtime installation command norrequirements.txtspecifies an exact version or verifies an integrity hash.As a result, the code ultimately executed can change after the Skill has been reviewed. A compromised upstream release, compromised package index, malicious index configuration, or dependency-resolution attack could introduce attacker-controlled installation or import-time code.
The subprocess invocation uses an argument list and does not expose a shell-injection flaw. The security issue is the implicit acquisition and execution of mutable third-party code.
Attack Path
- An attacker compromises a future
pdfmuserelease or influences the package source used by the environment. - The user invokes
scripts/read_jd.pywith a PDF or DOCX file on a system wherepdfmuseis not installed. read_jd()calls_ensure_pdfmuse()._ensure_pdfmuse()runs:bash python -m pip install -q pdfmuse- `pip ...[truncated 820 chars]
- An attacker compromises a future
- Remediation
View remediation
Remediation Suggestions
- Remove automatic package installation from normal document-processing execution.
- Require dependencies to be installed through an explicit, user-approved setup step.
- Pin
pdfmuseto a reviewed exact version instead of using an unconstrained package name. - Use a lock file or hash-verified requirements file, for example:
text pdfmuse==REVIEWED_VERSION --hash=sha256:REVIEWED_DISTRIBUTION_HASH - Install dependencies in a dedicated virtual environment with least-privilege permissions.
- Configure an approved package index and disable untrusted supplemental indexes.
- Fail safely with installation instructions when the dependency is missing rather than modifying the environment automatically.
- Add dependency-update review and vulnerability scanning to the release process.
