T03 · Remote Payload Retrieval and Execution
- Location
scripts/install_train_env.sh:10- Finding
Unverified Mutable Miniconda Installer Is Downloaded and Executed
- Content
View full analysis
Vulnerability Details
File Location:
scripts/install_train_env.sh, lines 10–16
Vulnerability Type: Remote payload retrieval and execution without integrity verification
Risk Level: Highbash if [ ! -d ~/miniconda3 ]; then echo "--- Install Miniconda ---" cd ~ if [ ! -f Miniconda3-latest-Linux-x86_64.sh ]; then wget -q https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh fi bash Miniconda3-latest-Linux-x86_64.sh -b -p ~/miniconda3 fiTechnical Analysis
The installation script downloads a mutable
latestartifact and executes it without validating a cryptographic checksum or signature. HTTPS protects the connection in ordinary circumstances but does not establish that the downloaded artifact is the exact version reviewed by the project.The script also trusts an existing file named
~/Miniconda3-latest-Linux-x86_64.sh. If that predictable file is already present, the download is skipped and the existing file is executed. Consequently, a local attacker or another compromised process with write access to the account’s home directory can replace the installer before this script runs.Because the external artifact can change independently of this repository, the effective executable payload cannot be determined solely by auditing the project.
Attack Path
- An attacker compromises the upstream distribution channel, the retrieved artifact, or a process with write access to the target user’s home directory.
- In the local planting scenario, the attacker creates a malicious file at
~/Miniconda3-latest-Linux-x86_64.sh. - The user or Agent runs
scripts/install_train_env.sh, either locally or through the documented SSH workflow. - The script detects the existing predictable filename and skips downloading a clean copy, or downloads a compromised mutable artifact.
- The script invokes the file with
bash, executing the attacker’s command ...[truncated 508 chars]
- Remediation
View remediation
Remediation Suggestions
- Pin a specific Miniconda release rather than using the mutable
latestfilename. - Store the expected vendor-published SHA-256 or stronger digest in the repository and verify it before execution.
- Download into a private temporary directory created with
mktemp -d, rather than into the user’s home directory. - Use a fixed output filename and fail closed if downloading or validation fails.
- Do not execute a pre-existing installer unless it passes the same integrity check.
- Remove the temporary installer after successful installation.
- Avoid running the setup script as
root.
Example hardening pattern:
bash version="py310_25.1.1-2" expected_sha256="VENDOR_PUBLISHED_SHA256" tmp_dir="$(mktemp -d)" trap 'rm -rf "$tmp_dir"' EXIT installer="$tmp_dir/miniconda.sh" wget --https-only \ "https://repo.anaconda.com/miniconda/Miniconda3-${version}-Linux-x86_64.sh" \ -O "$installer" printf '%s %s\n' "$expected_sha256" "$installer" | sha256sum --check - bash "$installer" -b -p "$HOME/miniconda3"- Pin a specific Miniconda release rather than using the mutable
