Elastic medium stable kql

Container Image Built Inside a Container

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.

View Source

Detection Logic

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

False Positives

  • ⚠ 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".

Field Validations

Loading…

Comments (0)

Loading comments...