heroui logo

Container Image Built Inside a Container

Elastic Detection Rules

View Source
Summary
This Elastic Defend for Containers rule detects when a container image is built from inside a running container, using build utilities such as docker build, buildah, buildctl, img, or nerdctl. Localized image builds bypass registry-based image scanning and admission controls, enabling attackers to assemble and run tooling without pulling a flagged image. Nested builds inside Kubernetes pods are rarely legitimate outside dedicated CI/build namespaces. The rule leverages container process events to identify shell or binary activity for common image builders within a container, and surfaces context to support investigation and containment. False positives commonly arise from in-pod CI/CD pipelines that perform in-container builds (e.g., Tekton, Argo Workflows, Jenkins, Kaniko). Mitigation requires baselining these pipelines and applying exceptions by orchestrator.namespace. Investigations should correlate with subsequent activity (e.g., the built image being run, pushed, or used to deploy privileged or host-namespaced pods) and may involve capturing the build context and Dockerfile, isolating the source container, and tightening RBAC/admission controls to prevent in-cluster image builds outside approved pipelines. The rule maps to MITRE ATT&CK T1612 (Build Image on Host) under Defense Evasion, indicating an attempt to bypass defenses by creating images within the container runtime rather than from trusted registries.
Categories
  • Containers
Data Sources
  • Process
  • Container
ATT&CK Techniques
  • T1612
Created: 2026-11-13