T08 · Insecure Dependencies
Error
- Location
- scripts/scan.sh:39
- Finding
- Automatic Execution of Dependencies from Untrusted Target Repositories<![CDATA[ ## Vulnerability Details **File Location**: `scripts/scan.sh:39-40` **Vulnerability Type**: Unsafe dependency installation from an untrusted repository **Risk Level**: High ### Vulnerable Code ```bash # Install deps [ -f "package.json" ] && npm install --silent 2>/dev/null || true [ -f "requirements.txt" ] && pip3 install -r requirements.txt --quiet 2>/dev/null || true ``` ### Technical Analysis The script accepts an arbitrary repository URL, clones that repository, and then automatically runs its dependency installation procedures. The cloned repository must therefore be treated as attacker-controlled input. Running `npm install` can execute package lifecycle scripts such as `preinstall`, `install`, and `postinstall`. These scripts can contain arbitrary commands. Similarly, installing Python dependencies can execute attacker-controlled build backends, source-distribution build logic, or legacy setup code. The dependencies are not validated against an allowlist, isolated from the host, or required to use cryptographic hashes. The installation commands run with the full permissions of the user who invoked the Skill. Suppressing errors and continuing with `|| true` also reduces visibility into malicious or unexpected installation behavior. Dependency installation may sometimes be necessary to compile a target, but automatically performing it on the host exceeds the minimum privileges required for static source analysis. ### Attack Path 1. An attacker creates or compromises a smart-contract repository. 2. The repository contains one of the following: - A malicious npm lifecycle script in `package.json`. - A dependency that executes malicious npm lifecycle code. - A malicious Python source package or build backend referenced by `requirements.txt`. 3. The attacker persuades a user to scan the repository or submits it as a purported bounty target. 4. The user runs: ```bash bash scripts/scan.sh <attacker-controlled-repository-url> ...[truncated 901 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Do not install dependencies from scanned repositories directly on the host. - Perform compilation and analysis in a disposable, unprivileged container or virtual machine. - Disable network access during dependency installation and scanning unless explicitly required. - Do not mount SSH agents, cloud credentials, wallet files, Docker sockets, or sensitive host directories into the sandbox. - Apply read-only filesystems, CPU and memory limits, process limits, and a dedicated non-root user. - Require explicit user confirmation before any dependency installation. - For npm projects, prefer a reviewed lockfile and use `npm ci --ignore-scripts` where compatible. - For Python projects, use a disposable virtual environment, require hash-pinned dependencies, and avoid unreviewed source distributions or build backends. - Display installation failures instead of suppressing all diagnostics. - Consider making dependency installation an opt-in mode separate from the default static scan. ]]>
