Skip to content
Threat Feed
medium advisory

Defense Evasion via In-Container Image Building

The detection of container image build utilities (e.g., docker, buildah, nerdctl) executing within a running container indicates a potential attempt to bypass security admission controls and registry scanning.

Triage facts

Revision 1
Applicability
Linux
Evidence
Unknown
Severity
Medium
Action
Elevated
Sources
2 public sources
Freshness
Revision 1Nov 16, 10:21 UTC
Source quality
A1Likely

Overview

Adversaries may build container images directly within a running container or pod to evade standard security controls. By assembling an image locally from a Dockerfile and executing it, attackers bypass defenses that typically inspect images pulled from a central registry. While legitimate in dedicated CI/CD pipelines (e.g., Tekton, Argo, Jenkins, Kaniko), this behavior is anomalous in standard production workloads and often signals manual, hands-on-keyboard post-exploitation activity.

Impact

Successful execution of this technique allows an adversary to assemble and run custom malicious tooling without triggering registry-based image scanning or admission control policies, potentially facilitating the deployment of privileged or host-namespaced pods.

Recommendation

Detection engineers should monitor for the execution of build utilities within containers. For organizations using Elastic, deploy the "Container Image Built Inside a Container" rule and baseline sanctioned build namespaces to reduce false positives.

Response and Remediation

  • Investigate the target container and namespace to determine if it is a sanctioned CI/CD workload.
  • Analyze the command line for the build context, Dockerfile path, and image tag.
  • Inspect the parent process to identify whether the build was invoked manually or via an automated process.
  • Isolate suspicious containers and remove unauthorized images to maintain environment integrity.

Immediate actions

Deploy detection rule for in-container build utilities targeting docker, buildah, and nerdctl.

Detection Engineering 48h

Threat Hunt

Identify execution of docker, buildah, or nerdctl within container workloads outside of dedicated CI/CD namespaces.

T1612 high high confidence hunt now

Data: Container process execution logs (e.g., Elastic Defend, Sysmon for Linux), Orchestrator namespace metadata