T1612: Build Image on Host
Adversaries may build a container image directly on a host to bypass defenses that monitor for the retrieval of malicious images from a public registry. A remote build
request may be sent to the Docker API that includes a Dockerfile that pulls a vanilla base image, such as alpine, from a public or local registry and then builds a custom image upon it.
An adversary may take advantage of that build
API to build a custom image on the host that includes malware downloaded from their C2 server, and then they may utilize Deploy Container using that custom image. If the base image is pulled from a public registry, defenses will likely not detect the image as malicious since it’s a vanilla image. If the base image already resides in a local registry, the pull may be considered even less suspicious since the image is already in the environment.
Detection
ID | DS0007 | Data source and component | Image: Image Creation | Description | Monitor for unexpected Docker image build requests to the Docker daemon on hosts in the environment. |
---|
ID | DS0029 | Data source and component | Network Traffic: Network Connection Creation | Description | Monitor for established network communications with anomalous IPs that have never been seen before in the environment that may indicate the download of malicious code. |
---|
ID | DS0029 | Data source and component | Network Traffic: Network Traffic Content | Description | Monitor for network traffic associated with requests and/or downloads of container images, especially those that may be anomalous or known malicious. |
---|
ID | DS0029 | Data source and component | Network Traffic: Network Traffic Flow | Description | Monitor for established network communications with anomalous IPs that have never been seen before in the environment that may indicate the download of malicious code. |
---|
Mitigation
ID | M1035 | Name | Limit Access to Resource Over Network | Description | Limit communications with the container service to local Unix sockets or remote access via SSH. Require secure port access to communicate with the APIs over TLS by disabling unauthenticated access to the Docker API on port 2375. Instead, communicate with the Docker API over TLS on port 2376. |
---|
ID | M1026 | Name | Privileged Account Management | Description | Ensure containers are not running as root by default. In Kubernetes environments, consider defining Pod Security Standards that prevent pods from running privileged containers. |
---|
ID | M1030 | Name | Network Segmentation | Description | Deny direct remote access to internal systems through the use of network proxies, gateways, and firewalls. |
---|
ID | M1047 | Name | Audit | Description | Audit images deployed within the environment to ensure they do not contain any malicious components. |
---|