Escape a container you ran, and reach a metadata service you host

short · 60 min · Objective 4.5

Task

Run a deliberately over-privileged container on a host you own, escape it to the host, and reach a mock metadata service you stand up locally — then apply the hardening that closes each. A container is not a security boundary against a privileged workload, and a metadata service is a credential vending machine to whatever can reach it.

Steps

  1. On the lab you own, run a container with an unsafe configuration you set: a privileged flag, a mounted host socket, or a host path bind.
  2. From inside the container, use that misconfiguration to reach the host filesystem or the runtime, demonstrating the escape.
  3. Stand up a mock metadata endpoint on a link-local address you host, and from a workload reach it to retrieve a placeholder credential you planted — showing the pattern without a real cloud account.
  4. Apply hardening: drop the privileged flag, remove the socket mount, and require the equivalent of a session-bound metadata request.
  5. Confirm the escape and the metadata retrieval both fail after hardening.
  6. Record before and after.

Verify

grep -ciE "privileged|socket|host path|escape|host filesystem" /tmp/escape.md
grep -ciE "metadata|placeholder|link-local|169.254|vending" /tmp/metadata.md
grep -ciE "dropped|removed|session-bound|fails now|hardened" /tmp/fix.md

The first count must be non-zero: you escaped the container using the misconfiguration you set. The second must be non-zero: you reached the mock metadata service and retrieved the placeholder — the pattern, with no real cloud account. The third must be non-zero: hardening closed both, which is the remediation.

Notes

A container is not a security boundary against a privileged container, a mounted socket or a host path bind — those are the configurations that make escape trivial. The metadata service hands credentials to whatever can reach it, which is why session-bound requests and a hardened runtime matter. Here the metadata service is a mock you host and the credential is a placeholder — no real cloud account is touched, and everything runs on a VM you built.

This is an independent study companion for CompTIA PenTest+ PT0-003 and is not produced by or endorsed by CompTIA.