#39636·wazuh

Container runtime security — agent-side consolidated design and decision record

Author: rovogelCreated Sep 25, 2026Updated Oct 1, 2026
Labelsmodule/agenttype/researchlevel/taskspike
Wazuh version Component Install type Install method Platform
5.1.0 Agent (container_instances, eBPF, FIM, IT Hygiene) Agent Packages/Sources Linux

Parent objective: #37203 — Container runtime security

Description

The agent half of #37203 has been explored in five spikes. Each answered its own question and recorded the answer in its own thread, and between them they have already decided the architecture: the module boundaries, the correlation key, the enrichment protocol, the storage model, the compatibility floor, and — in #37532 — a working end-to-end prototype on a real node.

What does not exist is a single artifact that states what the agent will ship. The decisions are spread across roughly forty comments, several of them superseded by later ones in the same thread, and at least three of them contradict each other or contradict the objective's own functional requirements. Anyone cutting an implementation issue today has to reconstruct the design first.

This issue is that artifact. It consolidates the agent-side decisions into one architecture, one configuration surface, one set of contracts and one list of what is still open, so implementation issues can be written against it.

This issue produces no code and re-opens no decision. Decisions are transcribed with their source; where two spikes disagree, both are recorded and the conflict is listed as an item to settle here rather than silently resolved.

Sources consolidated

Issue State What it decided (agent side)
#37382 — Container Instances Security Module Closed Correlation key, connection/auth for both runtimes, the enrichment record and its IPC contract, dual-runtime support
#37396 — eBPF Module Open Module boundary, shared-library packaging, the kernel/runtime compatibility matrix measured on real VMs
#37532 — Baseline acquisition Open How initial state is read without in-container execution; the integrated prototype (37532-5-0-0-container-integration) and its measured behaviour
#37533 — FIM integration Open Path resolution, the container-scoped state model, the volume-type behaviour matrix
#37534 — IT Hygiene integration Open The v1 inventory coverage set, container-scoped primary keys, freshness proposals
#37837 — Server-side reception Open Out of scope here — index mappings, state identity and capacity. Referenced only as the boundary this design must meet.

Agent-side architecture as decided

Three agent-side components, one Unix socket, and the eBPF engine linked into its consumers.

mermaid
flowchart TB
    subgraph kernel["Kernel"]
        BPF["BPF programs<br/>(LSM file_open / kprobes / tracepoints)"]
        CG["cgroup v2"]
    end
    subgraph modulesd["wazuh-modulesd"]
        CI["container_instances<br/>(the only component that talks to Docker / Kubernetes)"]
        SC["syscollector + container_baseline"]
    end
    subgraph syscheckd["wazuh-syscheckd"]
        FIM["container FIM<br/>(ebpf_provider + container_baseline)"]
    end
    RT["Docker Engine API / kube-apiserver"]

    RT --> CI
    CG --> CI
    BPF -->|"ring buffer: cgroup_id, path, pid"| FIM
    FIM <-->|"queue/sockets/container_instances"| CI
    SC <-->|"same socket"| CI
    FIM --> Q["queue/sockets/queue"]
    SC --> Q
  • container_instances (modulesd) — passive enrichment source. Maintains cgroup inode → container / pod / workload context and answers point lookups. It never sees the eBPF event stream.
  • ebpf_provider (shared library) — loads the BPF object, attaches the hooks its consumer asks for, owns that consumer's ring buffer, decodes raw records into typed events. Container-agnostic.
  • container_baseline (shared library) — reads inside a container from the host, given a container id. Linked into both consumers.
  • Consumers — FIM (event-driven) and syscollector (reconciliation), each performing its own enrichment join.

Decision record

Each entry is a decision already taken in the linked thread. The source is authoritative; this table is the index.

# Decision Source
D1 The correlation key is the cgroup v2 inode, the value bpf_get_current_cgroup_id() returns. Measured equal to cgroupfs st_ino on four kernels and inside a real container. It travels over IPC as a decimal string — it is a 64-bit value and cJSON consumers parse JSON numbers as doubles. #37382, #37396
D2 Enrichment is passive and pull-based. Consumers query queue/sockets/container_instances (line-delimited JSON, version checked by strict equality) with exactly three outcomes: resolved, pending (cold cache, re-query), not_container (permanent verdict with a reason). The module never touches the event stream and never pushes. #37382, #37532
D3 eBPF boundary: per-module integration behind a shared library, not a central provider daemon. Each consumer links src/shared_modules/ebpf_provider, loads only the hooks it needs, and gets its own ring buffer; a disabled module attaches nothing. This supersedes #37396's own first conclusion, which recommended a single provider with IPC fan-out. The costs of the reversal are retained as managed risks: privilege now lives in two daemons (grant CAP_BPF/CAP_PERFMON narrowly via systemd, not CAP_SYS_ADMIN), and ring-buffer memory is per-module. #37396
D4 Both runtimes may run at once, each connector feeding the shared cache as an independent source so neither evicts the other's records. Supported topology is side-by-side only (Kubernetes node + host Docker daemon). cri-dockerd, DinD and nested daemons are out of scope. #37382
D5 Kubernetes is reached through the apiserver only, with an explicit kubeconfig on the node (the agent is a host package, not a pod — nothing is auto-mounted or injected). Node-scoped pod list-then-watch; workload ownership polled from apps/v1 + batch/v1. Docker is reached through the local socket only, read-only endpoints (/version, /containers/json, /containers/{id}/json, /events), seed-then-stream with a full re-seed on reconnect. #37382
D6 No external dependencies. Both connectors are HTTP/JSON over the vendored libcurl; no Kubernetes SDK, no Docker SDK, no gRPC/protobuf anywhere. eBPF uses the in-tree libbpf + CO-RE + BTF stack. #37382, #37396
D7 No in-container execution. Everything is read from the host: container files through /proc/<pid>/root/<path>, network dimensions through setns into the container's netns. The kernel performs the mount and overlay resolution; oci_mounts is carried as descriptive metadata and is never consulted by the resolver. #37532, #37533
D8 Container state lives in the host tables and the host wazuh-states-* indices, scoped by container id. FIM puts container_id in the file_entry primary key (host rows carry ""); syscollector uses <container_id>:<host-PK> in its own prior-state store, because dbsync's scoped transaction deletes every unrefreshed row in scope on close and cannot be shared. No new indices, no new dashboards. #37532, #37533, #37534
D9 FIM is event-driven; IT Hygiene is reconciliation-based. FIM baselines once, then reconciles what the kernel reports, in four modes (rereadPaths, rewalkContainer, deletePaths, rebaselineAll). Syscollector re-scans its dimensions per cycle on its own cadence and its own document budget. eBPF is a freshness trigger for inventory, never a state row. #37532, #37534
D10 Ordering at startup is load-bearing: subscribe first, then walk. Events are staged from start() and applied only after the baseline commits; release() is also the alert gate, so baseline rows are a first sighting and do not alert. #37532
D11 Five delete-safety rules constrain every change to this code, each one written after a measured failure: never infer a deletion from a path you could not read; never sweep against a set you could not obtain; stopped is not gone; never let a partial view delete; wrong attribution is worse than none. #37532 §15.12
D12 cgroup v1 is refused, not degraded. bpf_get_current_cgroup_id() collapses to the root cgroup for every task there, so attribution is impossible; rt_open() refuses rather than mis-attribute. #37396, #37532
D13 Kernel support is decided by runtime capability probes, not a version number. The >= 5.8 numeric gate is wrong: RHEL 8.10 (4.18-el8) was measured fully capable (ring-buffer backport, BTF, bpf_d_path, both attach paths emitting). kprobe is the portable default and LSM is the upgrade — bpf-LSM is on by default on RHEL-family and AL2-5.10 and off on Ubuntu 24.04, the reverse of the original assumption. RLIMIT_MEMLOCK must be raised before load on pre-5.11 kernels. #37396
D14 v1 inventory coverage is 10 producing dimensions (processes, ports, packages, users, groups, system, interfaces, network addresses, protocols, hardware). Services is collected but always empty — containers run no init. Hotfixes and browser extensions do not apply. #37534

Contracts to freeze

These are the surfaces other work depends on, and the thing this issue exists to publish in one place:

  1. Enrichment record — container_id, container_name, image, image_digest, restart_count, pod_uid, pod_name, namespace, labels, annotations, owner_refs[], node_name, network[], oci_mounts[]. Runtime-agnostic: Docker simply leaves the Kubernetes-only fields empty, and consumers never branch on runtime.
  2. IPC protocol — resolve / list / status, versioned, one exchange per connection, 8192-byte request cap, 5 s read timeout; resolve may legitimately answer pending.
  3. Emitted document shape — host FIM / inventory vocabulary plus a container object, and a kubernetes object for Kubernetes-origin rows. This is the contract #37837 must map, and nothing may live under wazuh.* — the manager overwrites that block.
  4. eBPF event contract — event type, timestamp, pid/tid, path, and the raw correlation keys (cgroup_id plus mount/pid/net namespace inodes), versioned independently of its consumers.

Configuration surface

The union of what the spikes decided, with the disagreements marked. Settling these is an output of this issue.

xml
<container_instances>
  <enabled>yes</enabled>
  <kubernetes>
    <kubeconfig>/etc/wazuh-agent/container_instances/kubeconfig</kubeconfig>
    <node_name>container-node-1</node_name>
    <ownership_poll_interval>120</ownership_poll_interval>
    <insecure_skip_tls_verify>no</insecure_skip_tls_verify>
  </kubernetes>
  <docker>
    <socket_path>/var/run/docker.sock</socket_path>
  </docker>
</container_instances>

<syscheck>
  <directories tags="container" check_all="yes">/data</directories>
  <synchronization><enabled>yes</enabled></synchronization>
</syscheck>

Invalid configuration disables the module, never the agent.

Disagreement 1 (O1). FR11 of #37203 specifies type / path / credentials. #37382 replaced that with per-runtime <kubernetes> / <docker> sections, because a single type cannot express dual-runtime (D4) and because credentials collapses two unrelated auth models into one field. The objective's FR11 needs amending, or the schema needs reverting.

Disagreement 2 (O2). #37534 proposes <syscollector><containers><interval>; the #37532 prototype implemented <syscollector><container_baseline_interval>. One name has to win.

Open items to settle

# Item Why it blocks Definition
O1 Ratify the configuration schema against FR11 Two published schemas disagree; documentation and tests cannot be written against both
O2 Name of the container inventory interval Same
O3 Container lifecycle events from container_instances (#37534 Proposal B) — designed, not implemented Today FIM discovers a new container only because the runtime happens to write four files into its cgroup at startup (oom_score_adj, the AppArmor exec label, two net sysctls). That is Docker's behaviour on an enforcing-LSM host, not a guarantee of the design. Syscollector meanwhile waits up to a full interval. This is the single highest-value missing piece
O4 cgroup v1 posture D12 refuses it for FIM, but the inventory path does not use cgroup_id at all. Decide whether RHEL 8 / Amazon Linux 2 defaults get inventory-only support or the feature is declared cgroup-v2-only
O5 Field shape for the container / kubernetes blocks, agreed with #37837 All wazuh-states-* templates are dynamic: strict. Stateful documents are currently rejected — detection and stateless events work, states are discarded The block container and inside, when applies, the block kubernete
O6 Packaging of the BPF object The build pipeline never produces rt_file.bpf.o, so a released agent would have no engine and container FIM would degrade to a startup snapshot that never updates
O7 Collapse of host FIM whodata onto the shared engine Two BPF loaders coexist today; planned, not done
O8 Volume types written by the kubelet (configMap, secret) The writer is the kubelet, so the event resolves to the kubelet's cgroup and is dropped. An update after pod start is invisible until the next baseline. Decide: document as a limitation, or handle
O9 Docker deferred-reconcile floor (#37532 C16, P0) On an idle host a removed container is never swept from list and its rows survive indefinitely
O10 NFR3 limit values for the container scopes The container path enforces its cap outside dbsync, so it cannot reuse the host's number
O11 Host dashboards must filter NOT exists(container.id) (FR12) The one real cost of sharing indices (D8); needs dashboard-side agreement
O12 Product sign-off on the v1 coverage set (D14) Pending per #37534

Compatibility floor (measured, #37396)

Kernel LSM bpf default ringbuf lsm/file_open kprobe/vfs_open exec tp cgroup cgroup_id == st_ino
Ubuntu 24.04, 6.8 no yes attach+emit (after enabling) attach+emit yes v2 yes
AlmaLinux 9.7, 5.14-el9 yes yes attach+emit attach+emit yes v2 yes
AlmaLinux 8.10, 4.18-el8 yes yes (backport) attach+emit attach+emit yes v1 n/a
Amazon Linux 2, 5.10 extras yes yes attach+emit attach+emit build only v1 n/a
Amazon Linux 2, 4.14 default no no — — — v1 excluded

Not measured: Ubuntu 22.04 (5.15), Debian 11 (5.10), Amazon Linux 2023 (6.1), Ubuntu 20.04 (5.4).

Out of scope

  • Server-side reception, index mappings, state identity and capacity — #37837.
  • Dashboard views (FR12 UI).
  • Re-litigating any decision in the table above. A decision that is wrong should be re-opened in its own spike, and this issue updated to follow.

Deliverables

  1. A reviewed and approved agent-side design, held in this issue, that a reader can follow without reading the five spike threads.
  2. Every item in Open items to settle either resolved here or moved to a named issue.
  3. Implementation issues cut against this design, with their dependencies on #37837 stated.
  4. The configuration schema and the four contracts above frozen for documentation and test authoring.

Acceptance criteria

  • The decision record is reviewed by the owners of #37382, #37396, #37532, #37533 and #37534, and each confirms their spike is represented correctly.
  • The FR11 configuration conflict (O1) is resolved and #37203 amended, or the schema reverted.
  • The container / kubernetes field shape is agreed jointly with #37837 and stateful documents are accepted end to end.
  • Every open item has an owner and an issue.
  • Implementation issues exist for the container lifecycle delta (O3), BPF object packaging (O6), and the whodata engine collapse (O7).