Skip to content

About

Runtime security audit engine for Docker containers against CIS Benchmark v1.6.0. Inspects cgroup limits, kernel capabilities and seccomp filters, and exports SARIF 2.1.0 for CI/CD gates.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Python CIS Docker Benchmark SARIF

tests coverage license

Rule catalog · Quick start · CI integration · License

 

🪄 About

DockerWard audits live Docker daemons and inspects running containers against the CIS Docker Benchmark v1.6.0. Static image scanners (Trivy, Grype, Clair) find vulnerable packages at build time, but they are blind to how a container is executed: a 100% CVE-free image becomes an open door to the host if it runs with misconfigured runtime flags. DockerWard closes that gap.

Risk vector Static image scanner (build time) DockerWard (runtime)
Outdated openssl in a Debian image ✅ Detected ℹ️ Out of scope (build time)
Container started with --privileged ❌ Blind (set at docker run) ✅ CRITICAL
Docker socket bind-mounted (/var/run/docker.sock) ❌ Blind ✅ CRITICAL / HIGH
No memory/CPU limits (cgroups omitted) ❌ Blind ✅ MEDIUM
Dangerous capabilities added (--cap-add=SYS_ADMIN) ❌ Blind ✅ HIGH
Seccomp disabled (--security-opt seccomp=unconfined) ❌ Blind ✅ HIGH

Note

DockerWard is the third layer of an infrastructure security series: the host with archforge (Linux hardening, nftables, sysctl), the pipeline with Repo Secret Auditor (secrets and SARIF gates), and the container runtime with DockerWard.

 

🏛️ Architecture

flowchart LR
    subgraph Host["Docker host"]
        Socket["/var/run/docker.sock"]
        Containers["Running containers"]
    end
    subgraph Collector["Collector"]
        Mgr["DockerClientManager<br/>(proactive daemon diagnostics)"]
        Insp["ContainerInspector<br/>(raw Engine parser)"]
        Models["Pydantic telemetry models<br/>(security, caps, cgroups, mounts)"]
    end
    subgraph Engine["Policy & rules engine"]
        PolEng["PolicyEngine<br/>(sorting, filtering, failure gate)"]
        Rules["CIS rules (WARD-001..006)<br/>BaseRule ABC · dynamic severity · granular findings"]
    end
    subgraph Reporters["Exporters"]
        RichRep["Rich terminal table<br/>(executive summary)"]
        JSONRep["Machine JSON<br/>(CI/CD)"]
        SARIFRep["OASIS SARIF 2.1.0<br/>(GitHub Code Scanning)"]
    end
    Socket --> Mgr
    Containers --> Insp
    Mgr --> Insp --> Models --> PolEng
    Rules --> PolEng
    PolEng --> RichRep
    PolEng --> JSONRep
    PolEng --> SARIFRep
Loading
Design decision
🐚 Zero shell invocation Talks to the Docker Engine API over the Unix socket with docker-py: no fragile CLI parsing, no subshells.
🧯 Fail-safe evaluation Each rule runs inside its own exception boundary; an edge case in one rule never stops the rest of the audit.
🎯 Granular findings Resource and capability violations get distinct sub-IDs (WARD-004A/B/C, WARD-005A/B) with a specific remediation each.

 

📋 Rule catalog

Rule CIS Title Severity Core risk
WARD-001 4.1 Container running as root (UID 0) HIGH UID 0 shared with the host kernel without user namespace mapping
WARD-002 5.4 Privileged mode CRITICAL Device cgroup lifted, every capability granted: trivial escape
WARD-003 5.31 Docker socket mounted CRITICAL / HIGH RW runs daemon commands; RO leaks sibling containers' secrets
WARD-004A 5.10 No memory limit MEDIUM Unbounded memory triggers the host's OOM killer
WARD-004B 5.11 No CPU limit MEDIUM Uncapped CFS quota starves neighbouring workloads
WARD-004C 5.28 No PIDs limit MEDIUM A fork bomb can exhaust the host's process table
WARD-005A 5.3 Dangerous capabilities granted HIGH SYS_ADMIN, NET_ADMIN and similar break isolation
WARD-005B 5.3 Baseline capabilities not dropped LOW No least-privilege baseline (--cap-drop=ALL)
WARD-006 5.21 Default seccomp profile disabled HIGH seccomp:unconfined unblocks 300+ raw system calls
Linux kernel internals behind each rule

WARD-001 · root user and user namespaces. Containers share the host kernel. Without user namespace mapping (CONFIG_USER_NS), UID 0 inside the container is UID 0 on the host process table, so any kernel bug, escape or writable host mount grants full root on the host.

WARD-002 · --privileged. Disables the device cgroup controller (devices.allow = a *:* rwm), giving raw access to every host device (including /dev/sda) and all ~41 capabilities. An attacker can mount the host root drive or write to kernel memory.

WARD-003 · Docker socket. A Unix stream socket owned by root:docker. Read-write allows any API call, such as starting a helper container with -v /:/host --privileged; read-only still allows GET /containers/{id}/json, leaking environment variables, credentials and tokens of every other container.

WARD-004 · cgroups v1/v2. Without memory.max a leak exhausts RAM and swap and the OOM killer takes down system daemons; without CFS quotas (cpu.max) a runaway loop starves the CPU; without pids.max a 3-line fork bomb (:(){ :|:& };:) fills /proc/sys/kernel/pid_max and freezes the host.

WARD-005 · capabilities and bounding sets. Linux splits root into ~41 capabilities; Docker keeps ~14 by default. Adding CAP_SYS_ADMIN (mounts, cgroups) or CAP_NET_ADMIN (routing, firewall) neutralizes the boundaries. The CIS fix: drop all (--cap-drop=ALL) and add back only what's needed (--cap-add=CHOWN).

WARD-006 · seccomp-bpf. A programmable system call firewall. The kernel exposes ~330+ syscalls; Docker's default profile blocks ~44 high-risk ones (reboot, keyctl, process_vm_readv, acct). seccomp=unconfined removes the filter entirely.

 

🚀 Quick start

git clone https://github.com/h3n-x/DockerWard.git
cd DockerWard
python3 -m venv .venv && source .venv/bin/activate
pip install -e .
Command What it does
dockerward ping Check the connection to the Docker daemon
dockerward inspect [container] [--json] Deep telemetry of all running containers, or one
dockerward audit [container] Security audit as a terminal table with an executive summary
dockerward audit --format sarif -o results.sarif SARIF 2.1.0 for GitHub Code Scanning
dockerward audit --format json -o audit-report.json Machine-readable JSON
dockerward audit --fail-on HIGH Exit code 1 if any HIGH or CRITICAL finding exists (CI gate)

Tip

The repo includes a testbed with three postures to try it right away: docker compose -f docker-compose.test.yml up -d starts ward-victim-privileged (CRITICAL: root, --privileged, RW socket, unconfined seccomp, no limits), ward-victim-exposed (HIGH: root, CAP_SYS_ADMIN and CAP_NET_ADMIN) and ward-victim-hardened (safe control: UID 1000:1000, read-only root, --cap-drop=ALL, no-new-privileges, 128 MB / 0.5 CPU / 50 PIDs).

Example audit output
       Security Audit: ward-victim-privileged (86929020fc49) — 8 Finding(s)
┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┓
┃ Rule ID     ┃   Severity   ┃ CIS Benchmark          ┃ Finding & Desc     ┃ Remediat… ┃
┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━┩
│ WARD-002    │   CRITICAL   │ CIS Docker 1.6.0 - 5.4 │ Privileged mode    │ Remove    │
│ WARD-003    │   CRITICAL   │ CIS Docker 1.6.0 - 5.31│ Docker socket (RW) │ Remove    │
│ WARD-001    │     HIGH     │ CIS Docker 1.6.0 - 4.1 │ Running as root    │ USER 1000 │
│ WARD-006    │     HIGH     │ CIS Docker 1.6.0 - 5.21│ Seccomp unconfined │ Remove    │
│ WARD-004A   │    MEDIUM    │ CIS Docker 1.6.0 - 5.10│ No memory limit    │ --memory  │
│ WARD-004B   │    MEDIUM    │ CIS Docker 1.6.0 - 5.11│ No CPU limit       │ --cpus    │
│ WARD-004C   │    MEDIUM    │ CIS Docker 1.6.0 - 5.28│ No PIDs limit      │ --pids-l… │
│ WARD-005B   │     LOW      │ CIS Docker 1.6.0 - 5.3 │ Missing cap-drop   │ --cap-dr… │
└─────────────┴──────────────┴────────────────────────┴────────────────────┴───────────┘

✓ ward-victim-hardened (cec3debbc93f): Conforms to audited security benchmarks.

╭─ DockerWard Executive Security Summary ─╮
│ Scanned Containers                   3  │
│ Total Findings                      14  │
│   CRITICAL                           2  │
│   HIGH                               4  │
│   MEDIUM                             6  │
│   LOW                                2  │
╰─────────────────────────────────────────╯

 

⚙️ GitHub Actions

Scan runtime containers in any workflow and publish the results to Security → Code scanning alerts (.github/workflows/dockerward-audit.yml):

name: DockerWard Runtime Security Audit

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]
  workflow_dispatch:

jobs:
  runtime-audit:
    name: Audit Container Security Posture
    runs-on: ubuntu-latest
    permissions:
      security-events: write
      actions: read
      contents: read
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
          cache: "pip"
      - name: Install DockerWard
        run: pip install --upgrade pip && pip install .
      - name: Start target containers
        run: docker compose -f docker-compose.test.yml up -d
      - name: Run DockerWard and generate SARIF
        run: dockerward audit --format sarif -o results.sarif
      - name: Upload SARIF to GitHub Code Scanning
        uses: github/codeql-action/upload-sarif@v3
        if: always()
        with:
          sarif_file: results.sarif
          category: dockerward-runtime-audit
      - name: Enforce the security gate
        run: dockerward audit --fail-on HIGH

 

🧪 Testing

71 tests cover every rule in both violating and compliant cases, the container parsers and the SARIF exporter (91% coverage, 100% on the rules):

.venv/bin/pytest --cov=dockerward --cov-report=term-missing

 

📚 Documentation

Resource Description
CONTRIBUTING.md How to contribute
SECURITY.md Security policy and reporting
README.es.md This readme in Spanish

 

Copyright © 2026 h3n-x

MIT License

About

Runtime security audit engine for Docker containers against CIS Benchmark v1.6.0. Inspects cgroup limits, kernel capabilities and seccomp filters, and exports SARIF 2.1.0 for CI/CD gates.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages