2022-10-14 12:42:10 +00:00
|
|
|
-- Detect the execution of priveleged Docker containers which can be used to escape to the host.
|
|
|
|
--
|
|
|
|
-- references:
|
|
|
|
-- * https://attack.mitre.org/techniques/T1611/
|
|
|
|
--
|
2022-10-19 20:56:32 +00:00
|
|
|
-- false-positives:
|
|
|
|
-- * Nested Kubernetes Environments
|
|
|
|
-- * Containerized builds
|
|
|
|
--
|
2022-10-14 12:42:10 +00:00
|
|
|
-- This query works on macOS as well, but is only an in-the-wild security problem on Linux,
|
2022-10-14 13:16:24 +00:00
|
|
|
-- where the kernel namespaces can be shared. These kind of attacks tend to be
|
2022-10-14 12:42:10 +00:00
|
|
|
--
|
|
|
|
-- platform: linux
|
2022-10-14 18:19:13 +00:00
|
|
|
-- tags: transient state container escalation
|
2022-09-24 15:12:23 +00:00
|
|
|
SELECT
|
2022-10-17 23:06:17 +00:00
|
|
|
command,
|
|
|
|
image_id,
|
|
|
|
path,
|
|
|
|
security_options,
|
|
|
|
started_at,
|
|
|
|
image
|
2022-09-24 15:12:23 +00:00
|
|
|
FROM
|
|
|
|
docker_containers
|
|
|
|
WHERE
|
|
|
|
privileged = 1
|
2022-10-21 16:13:16 +00:00
|
|
|
AND image NOT LIKE 'kindest/node:%'
|
|
|
|
AND image NOT LIKE 'ghcr.io/k3d-io/k3d-%'
|
|
|
|
AND image NOT LIKE 'docker.io/rancher/k3s:%'
|
|
|
|
-- this one makes me sad. It's due to limitations running bubblewrap in a container
|
2022-11-03 15:51:54 +00:00
|
|
|
AND image NOT IN (
|
|
|
|
'cgr.dev/chainguard/melange',
|
|
|
|
'wolfi:test',
|
2022-11-18 15:27:43 +00:00
|
|
|
'distroless.dev/melange',
|
2022-11-03 15:51:54 +00:00
|
|
|
'distroless.dev/melange:latest'
|
2022-11-03 18:25:35 +00:00
|
|
|
)
|
|
|
|
AND command NOT LIKE '/usr/bin/melange build %'
|