Sketchy Docker Image Creator

osquery
Detect the execution of a Docker containing mounting the root filesystem
Author

Chainguard

Published

January 29, 2025

Description

ODK (osquery-defense-kit) is unique in that the queries are designed to be used as part of a production detection & response pipeline. The detection queries are formulated to return zero rows during normal expected behavior, so that they may be configured to generate alerts when rows are returned.

Query

-- Detect the execution of a Docker containing mounting the root filesystem
--
-- references:
--   * https://attack.mitre.org/techniques/T1611/
--   * https://github.com/liamg/traitor/blob/main/pkg/exploits/dockersock/exploit.go
--
-- This attack is very quick, so the likelihood of finding a culprit is entirely
-- dependent on the polling time. The number of "tags" you see associated to an image
-- may reflect the number of times the attack has been attempted.
--
-- platform: linux
-- tags: transient
SELECT
  *
FROM
  docker_image_history
WHERE
  created > (strftime('%s', 'now') -86400)
  -- This signature is used by Traitor: https://github.com/liamg/traitor/
  AND created_by LIKE '%/bin/sh%/lol%';

tags: SStagSS

Reference

https://github.com/chainguard-dev/osquery-defense-kit