mirror of
https://github.com/chainguard-dev/osquery-defense-kit
synced 2024-12-12 17:14:37 +00:00
42 lines
1.2 KiB
SQL
42 lines
1.2 KiB
SQL
-- Detect the execution of priveleged Docker containers which can be used to escape to the host.
|
|
--
|
|
-- references:
|
|
-- * https://attack.mitre.org/techniques/T1611/
|
|
--
|
|
-- false-positives:
|
|
-- * Nested Kubernetes Environments
|
|
-- * Containerized builds
|
|
--
|
|
-- This query works on macOS as well, but is only an in-the-wild security problem on Linux,
|
|
-- where the kernel namespaces can be shared. These kind of attacks tend to be
|
|
--
|
|
-- platform: linux
|
|
-- tags: transient state container escalation
|
|
SELECT
|
|
command,
|
|
image_id,
|
|
path,
|
|
security_options,
|
|
started_at,
|
|
image
|
|
FROM
|
|
docker_containers
|
|
WHERE
|
|
privileged = 1
|
|
AND image NOT LIKE 'kindest/node:%'
|
|
AND image NOT LIKE 'ghcr.io/k3d-io/k3d-%'
|
|
AND image NOT LIKE 'docker.io/rancher/k3s:%'
|
|
AND image NOT LIKE 'melange-%'
|
|
AND image NOT LIKE 'gcr.io/k8s-minikube/kicbase:%'
|
|
-- this one makes me sad. It's due to limitations running bubblewrap in a container
|
|
AND image NOT IN (
|
|
'cgr.dev/chainguard/melange',
|
|
'cgr.dev/chainguard/sdk',
|
|
'moby/buildkit:buildx-stable-1',
|
|
'cgr.dev/chainguard/wolfi-base',
|
|
'distroless.dev/melange',
|
|
'distroless.dev/melange:latest',
|
|
'wolfi:test'
|
|
)
|
|
AND command NOT LIKE '/usr/bin/melange build %'
|