T08 · Insecure Dependencies
- Location
scripts/shorten.py:96- Finding
Unpinned Third-Party Package Installation Guidance
- Content
View full analysis
Vulnerability Details
File Location:
scripts/shorten.py, lines 96-98
Vulnerability Type: Insecure third-party dependency installation guidance
Risk Level: LowComplete Code Snippet
python except ImportError: print("Error: qrcode not installed. Run: pip install qrcode[pil]") return 1Technical Analysis
When the optional QR-code dependency is unavailable, the script instructs the user to install
qrcode[pil]without specifying a reviewed version, package hash, lockfile, or trusted package index. The script does not automatically execute this command, so exploitation requires the user or an automation layer to follow the displayed guidance.Because the dependency is mutable and retrieved through the environment's configured Python package index, the installed implementation and its transitive dependencies can differ from those reviewed by the project. A compromised package release, compromised package index, or maliciously configured index could consequently introduce attacker-controlled code during package building, installation, or subsequent import.
Attack Path
- A user requests QR-code generation in an environment where
qrcodeis not installed. - The import fails and the script displays
pip install qrcode[pil]. - The user executes the suggested command.
pipresolves an unpinned package and its dependencies through the configured package index.- If the selected package, dependency, release, or index is compromised, attacker-controlled code may run during installation or when the package is imported on a later invocation.
Impact Assessment
Successful exploitation could execute code with the privileges of the user running
pipor the URL-shortener script. This may permit access to that user's files, environment variables, credentials, and network capabilities. The scope does not inherently include elevated system privileges unless installati ...[truncated 53 chars]- A user requests QR-code generation in an environment where
- Remediation
View remediation
Remediation Suggestions
- Declare the optional QR dependency in a reviewed dependency manifest rather than relying only on runtime installation instructions.
- Pin reviewed direct and transitive dependency versions.
- Provide a lockfile or hash-verified requirements file and recommend installation with hash verification, such as
pip install --require-hashes. - Document the trusted package index or repository from which dependencies must be obtained.
- Integrate dependency vulnerability and provenance checks into release workflows.
- Avoid recommending elevated installation commands.
