T03 · Remote Payload Retrieval and Execution
Error
- Location
- assets/Dockerfile.txt:3
- Finding
- Unverified Remote Installer Scripts Execute with Root Privileges<![CDATA[ ## Vulnerability Details **File Location**: `assets/Dockerfile.txt:3-24` **Vulnerability Type**: Unverified remote payload retrieval and privileged execution **Risk Level**: Critical ### Vulnerable Code ```dockerfile USER root # System essentials RUN apt-get update && apt-get install -y --no-install-recommends \ curl git wget unzip ca-certificates build-essential \ && rm -rf /var/lib/apt/lists/* # Bun (latest) RUN curl -fsSL https://bun.sh/install | bash \ && mv /root/.bun/bin/bun /usr/local/bin/ \ && mv /root/.bun/bin/bunx /usr/local/bin/ \ && rm -rf /root/.bun # uv (latest) RUN curl -LsSf https://astral.sh/uv/install.sh | sh \ && mv /root/.local/bin/uv /usr/local/bin/ \ && mv /root/.local/bin/uvx /usr/local/bin/ \ && rm -rf /root/.local # OpenCode (latest) RUN curl -fsSL https://opencode.ai/install | bash \ && find /root -name opencode -type f 2>/dev/null \ && cp /root/.opencode/bin/opencode /usr/local/bin/opencode || true ``` ### Technical Analysis The Docker build downloads installer scripts from three external URLs and immediately pipes their contents into `bash` or `sh`. These commands execute after `USER root`, giving each remotely supplied script unrestricted control over the image filesystem during the build. The downloaded content is not pinned to an immutable version and is not checked using a cryptographic digest or signature. HTTPS provides transport protection but does not establish that the retrieved script is the same content that was reviewed. A compromised upstream service, publishing account, CDN, DNS route, or future installer modification could therefore change the effective payload without any change to this project. The installers may require installation access, but executing mutable scripts as root exceeds the minimum privilege necessary. The required binaries could instead be obtained from versioned release artifacts and verified before installation. The OpenCode command als ...[truncated 1405 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove all `curl | bash` and `curl | sh` pipelines. 2. Pin Bun, uv, and OpenCode to explicit audited versions. 3. Download versioned release artifacts into files before installation. 4. Verify each artifact using a hardcoded SHA-256 digest or a validated upstream signature. 5. Abort the build when verification or installation fails; remove the OpenCode `|| true` failure suppression. 6. Perform downloads and extraction under an unprivileged build user where possible, elevating only for the final copy into a system directory. 7. Pin the `codercom/code-server` base image by immutable digest in addition to its version tag. 8. Use a multi-stage build so network-facing installation steps and unnecessary build tools are not retained in the final image. 9. Record approved versions and hashes in the repository so future upgrades require an explicit, reviewable change. ]]>
