T08 · Insecure Dependencies
- Location
scripts/prerequisites.sh:38- Finding
Unpinned Third-Party Python Package Installation
- Content
View full analysis
Vulnerability Details
File Location:
scripts/prerequisites.sh:38
Vulnerability Type: Unpinned dependency installation from a mutable package index
Risk Level: MediumVulnerable Code:
bash run_step "Installing jinjanator (j2)" \ bash -c 'pip3 install --user jinjanator || sudo apt-get install -y j2cli'Technical Analysis
The script installs
jinjanatorfrom pip without constraining its version or validating package integrity with cryptographic hashes. Consequently, the installed package and its transitive dependencies are resolved from the mutable default Python package index at execution time.If the upstream package, maintainer account, release process, or a transitive dependency is compromised, a later malicious release could be selected automatically. Python package installation may execute package-controlled build hooks or backend code. The resulting
j2executable also participates in subsequent SONiC build operations.The fallback to
j2clidoes not mitigate the supply-chain risk. It silently changes implementations when pip installation fails, produces nondeterministic environments, and invokesapt-getwith root privileges. There is no evidence that either named package is currently malicious; the confirmed issue is the unsafe, unpinned dependency-resolution mechanism.Related documentation repeats the unpinned installation guidance at
references/prerequisites.md:20andreferences/troubleshooting.md:7.Attack Path
- An attacker compromises the
jinjanatorpublisher account, release infrastructure, or one of its unconstrained dependencies. - The attacker publishes a malicious version that remains compatible with the unconstrained package requirement.
- A user runs
scripts/prerequisites.sh. pip3 install --user jinjanatorresolves and downloads the attacker-controlled release from the default package index.- Malicious package installation hooks can ex ...[truncated 771 chars]
- An attacker compromises the
- Remediation
View remediation
Remediation Suggestions
-
Pin
jinjanatorand every transitive Python dependency to audited versions in a committed lock file. -
Require cryptographic hashes during installation, for example:
bash python3 -m pip install --user --require-hashes -r requirements.txt -
Install dependencies in an isolated virtual environment rather than the user's global package context.
-
Use a trusted internal package mirror or a controlled artifact repository where packages are reviewed and immutable.
-
Fail closed if the expected package cannot be installed instead of silently switching to
j2cli. -
Update
references/prerequisites.mdandreferences/troubleshooting.mdto direct users to the pinned, hash-verified installation procedure. -
Periodically review and deliberately update locked dependencies using vulnerability and provenance checks.
-
