T03 · Remote Payload Retrieval and Execution
Error
- Location
- lib/docker-utils.sh:201
- Finding
- Unpinned Remote Container Image Executed with Host-Equivalent Privileges<![CDATA[ ## Vulnerability Details **File Location**: `lib/system-utils.sh:103-113`, `lib/docker-utils.sh:201-215`, `lib/docker-utils.sh:228-260` **Vulnerability Type**: Untrusted remote payload execution with excessive container privileges **Risk Level**: Critical ### Vulnerable Code ```bash get_image_name() { local arch="$1" case "$arch" in x86_64) echo "swr.cn-south-1.myhuaweicloud.com/cloud-lwops/lwops_rocky8_x86_image:latest" ;; aarch64) echo "swr.cn-south-1.myhuaweicloud.com/cloud-lwops/lwops_rocky8_arm_image:latest" ;; *) echo "" ;; esac } ``` ```bash docker_pull() { local image="$1" if [ -z "$image" ]; then return 1 fi if sudo docker pull "$image"; then return 0 else return 1 fi } ``` ```bash if sudo docker run -d \ --name "$container_name" \ --privileged \ -p "${host_port1}:80" \ -p "${host_port2}:8081" \ --hostname "$container_name" \ -v /sys/fs/cgroup:/sys/fs/cgroup:${cgroup_mode} \ "$image" \ /usr/sbin/init; then ``` ### Technical Analysis The Skill pulls images through the mutable `latest` tag rather than a content-addressed digest. The effective payload can therefore change after the Skill has been reviewed. No image signature, digest, provenance, or expected identity is verified before execution. The downloaded image is then run with `--privileged`. Privileged containers receive all Linux capabilities, broad device access, relaxed security restrictions, and a substantially enlarged kernel attack surface. The host cgroup hierarchy is also mounted into the container. In cgroup v2 environments, `execute.sh:241-245` selects `rw`, allowing the remote image to modify host cgroup state: ```bash local cgroup_mode="ro" if [ "$cgroup_version" = "v2" ]; then cgroup_mode="rw" fi ``` This combination effectively treats an externally controlled, mutable containe ...[truncated 1196 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Pin each image to a reviewed immutable digest, for example: ```bash image="registry.example/repository/image@sha256:EXPECTED_DIGEST" ``` 2. Verify image signatures and provenance using an appropriate mechanism such as Cosign or Docker Content Trust. 3. Remove `--privileged`. 4. Run the application as a non-root container user. 5. Start with `--cap-drop=ALL` and add only individually documented capabilities that are strictly required. 6. Add `--security-opt=no-new-privileges:true`. 7. Retain the default seccomp and AppArmor/SELinux restrictions. 8. Use a read-only container filesystem where possible. 9. Do not mount the host cgroup hierarchy. If compatibility absolutely requires access, expose the smallest possible read-only subset and document why it is necessary. 10. Refuse deployment if the expected digest or signature cannot be verified. ]]>
