T08 · Insecure Dependencies
- Location
scripts/shorten.py:101- Finding
Unpinned Third-Party Dependency Installation Guidance
- Content
View full analysis
Vulnerability Details
File Location:
scripts/shorten.py, lines 101-103
Vulnerability Type: Unpinned package installation from the default Python package registry
Risk Level: Mediumpython except ImportError: print("Error: qrcode not installed. Run: pip install qrcode[pil]") return 1Technical Analysis
When the optional
qrcodemodule is unavailable, the program instructs the user to installqrcode[pil]without specifying a reviewed version, dependency lockfile, package hashes, or trusted package index.Although the program does not automatically execute the installation command, following its explicit guidance causes pip to resolve the latest available package and transitive dependencies from the configured registry. Python packages can execute installation or build-related code, and subsequently execute code when imported. Consequently, the effective dependency implementation can change after this skill has been audited.
Attack Path
- A user invokes QR-code generation with
--qror--qr-file. - The
qrcodemodule is not installed, causing theImportErrorhandler to display the installation command. - The user runs
pip install qrcode[pil]as instructed. - Pip resolves an unpinned release and its transitive dependencies from the configured registry.
- If a resolved release, dependency, package index, or package distribution has been compromised, attacker-controlled code can execute during package installation or when
qrcodeis later imported. - That code executes with the privileges of the user or environment in which pip and the script are run.
Impact Assessment
Successful exploitation could execute arbitrary code with the privileges of the user performing the installation. Depending on that user's permissions and whether installation occurs inside an isolated environment, the attacker could access user-readable files, modify user-owned reso ...[truncated 305 chars]
- A user invokes QR-code generation with
- Remediation
View remediation
Remediation Suggestions
- Supply a reviewed dependency manifest that pins
qrcodeand all transitive dependencies to exact versions. - Include cryptographic hashes and install dependencies with a command such as
pip install --require-hashes -r requirements.txt. - Direct users to create an isolated virtual environment rather than installing packages globally or with elevated privileges.
- Document the expected trusted package index and prohibit unreviewed extra indexes.
- Integrate dependency vulnerability and integrity checks into the release process.
- Replace the unconstrained installation message with instructions referencing the project's reviewed dependency manifest.
- Supply a reviewed dependency manifest that pins
