T08 · Insecure Dependencies
Warning
- Location
- scripts/start_question_service.ps1:32
- Finding
- Automatic Installation of Unreviewed Runtime and Project Dependencies<![CDATA[ ## Vulnerability Details **File Location**: `scripts/start_question_service.ps1`, lines 32–34 and 52–54 **Vulnerability Type**: Unsafe automatic dependency installation **Risk Level**: Medium ### Vulnerable Code ```powershell if (-not (Test-Python)) { Write-Host "Python not found, trying winget install Python 3.12..." winget install -e --id Python.Python.3.12 --accept-package-agreements --accept-source-agreements $env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User") if (-not (Test-Python)) { Write-Error "Python still unavailable after install" } } ``` ```powershell Write-Host "Installing dependencies..." & $pythonExe -m pip install -q --upgrade pip & $pythonExe -m pip install -q -r (Join-Path $Root "requirements.txt") ``` ### Technical Analysis The service-start operation performs software installation as a side effect. If Python is unavailable, the script installs Python through Winget while automatically accepting package and source agreements. It then upgrades pip and installs every dependency listed in the enclosing QuizAI project's `requirements.txt`. The relevant `requirements.txt` is not included in the audited Skill package. Its package names, versions, hashes, index sources, and transitive dependencies therefore cannot be verified as part of this audit. Python package installation may execute package build backends, setup hooks, and other package-controlled code. The risk is amplified if dependencies are not pinned and hash-verified, or if the environment uses a compromised or attacker-controlled package index. A modified host-project `requirements.txt` can also introduce arbitrary packages without requiring changes to the reviewed Skill. ### Attack Path 1. An attacker modifies the enclosing project's `requirements.txt`, compromises a listed package, publishes a dependency-confusion package, or influences pip ...[truncated 942 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Separate dependency installation from service startup. The start script should only launch an already prepared environment. 2. Require explicit, informed user confirmation before installing Python, upgrading pip, or installing project dependencies. 3. Use a reviewed lock file containing exact dependency versions and cryptographic hashes. 4. Install dependencies with hash enforcement, such as: ```powershell & $pythonExe -m pip install --require-hashes -r requirements.lock ``` 5. Pin the package index to an approved HTTPS repository and prevent fallback to unintended extra indexes. 6. Do not automatically upgrade pip during every service start. Manage pip versions as part of a separate, reviewed setup process. 7. Validate the integrity and expected location of the host project's dependency file before using it. 8. Run installation and the application under a dedicated, least-privileged account or sandbox where practical. 9. Record dependency installation results and fail closed if package authenticity or integrity validation fails. ]]>
