Container Image Built Inside a Container

Last updated 4 days ago on 2026-11-13
Created 4 days ago on 2026-11-13

About

This rule detects a container image being built from inside a running container using a container build utility such as "docker build", "buildah", "buildctl", "img", or "nerdctl build". Building an image on the host (or inside a pod) bypasses defenses that monitor for the retrieval of malicious images from a public registry, allowing an adversary to assemble and run tooling without pulling a flagged image. Nested image builds inside a Kubernetes pod are rarely legitimate outside of dedicated CI/build namespaces.
Tags
Data Source: Elastic Defend for ContainersDomain: ContainersOS: LinuxUse Case: Threat DetectionTactic: Defense EvasionRule Type: ES|QLPlatform: LinuxPlatform: KubernetesLanguage: esql
Severity
medium
Risk Score
47
MITRE ATT&CK™

Defense Evasion (TA0005)(external, opens in a new tab or window)

False Positive Examples
CI/CD and image-build pipelines (for example Tekton, Argo Workflows, Jenkins, or Kaniko builders) legitimately build images inside pods. Baseline the build namespaces and service accounts used for those pipelines and add exceptions by "orchestrator.namespace".
License
Elastic License v2(external, opens in a new tab or window)

Definition

Integration Pack
Prebuilt Security Detection Rules
Related Integrations

cloud_defend(external, opens in a new tab or window)

Query
text code block:
from logs-cloud_defend.process* metadata _id, _index, _version | where host.os.type == "linux" and event.type == "start" and event.action == "exec" and container.id like "*" and process.name in ("docker", "docker-buildx", "buildah", "buildctl", "img", "nerdctl") and kql("""process.args: ("build" or "bud")""") | keep @timestamp, host.id, container.id, process.name, process.args, process.parent.name, process.parent.executable, user.id, _id, _index, _version

Install detection rules in Elastic Security

Detect Container Image Built Inside a Container in the Elastic Security detection engine by installing this rule into your Elastic Stack.

To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(external, opens in a new tab or window).