T08 · Insecure Dependencies
- Location
split_by_column.py:20- Finding
Unpinned Third-Party Dependency Installation Guidance
- Content
View full analysis
Vulnerability Details
File Location:
split_by_column.py, lines 20–24
Vulnerability Type: Unverified and unpinned third-party dependency installation
Risk Level: MediumVulnerable Code:
python try: from openpyxl import load_workbook, Workbook from openpyxl.styles import Font, PatternFill, Alignment from openpyxl.utils import get_column_letter except ImportError: print("Error: openpyxl is required. Install it first with: pip install openpyxl") sys.exit(1)Technical Analysis
When the dependency import fails, the script directs the user to install
openpyxlthrough an unpinnedpip installcommand. The project does not provide a lockfile, exact reviewed version, artifact hashes, or an explicit trusted package index.Consequently, dependency resolution is controlled by the user's active pip configuration and whichever package release is current at installation time. If the configured index, selected package release, or transitive dependency chain is compromised, installation may process attacker-controlled package content. Python packages can run build-related code during installation, particularly when pip builds a source distribution.
This is a supply-chain hardening weakness. The script does not itself download or execute a remote payload, and exploitation requires the user to follow the displayed installation instruction in an affected package-index environment.
Attack Path
- The user runs the script in an environment where
openpyxlis unavailable. - The import raises
ImportError, causing the script to display the unpinned installation command. - The user executes
pip install openpyxl. - Pip resolves the package and its dependencies using the environment's configured package indexes without project-supplied version or hash restrictions.
- A compromised index, malicious package release, or compromised dependency supplies an ...[truncated 745 chars]
- The user runs the script in an environment where
- Remediation
View remediation
Remediation Suggestions
-
Add a reviewed dependency manifest that pins
openpyxland all transitive dependencies to exact versions. -
Generate and verify cryptographic hashes for every approved distribution artifact.
-
Replace the generic installation guidance with a hash-enforcing command, for example:
bash python -m pip install --require-hashes -r requirements.txt -
Configure installation to use an explicitly approved HTTPS package index or an internally controlled package mirror.
-
Prefer pre-reviewed binary wheels where appropriate and prohibit unexpected source builds in automated environments.
-
Run dependency installation in an isolated virtual environment under a non-privileged account.
-
Add automated dependency vulnerability and integrity checks to the CI pipeline, and update pinned versions through a controlled review process.
-
