Techniques
Sample rules
Container Image Built Inside a Container
- source: elastic
- technicques:
- T1612
Description
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.
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