The Build Host That Answered Anyone: Inspecting Containers Through an Open Docker API

Cloud Security Level 2/4 ~3 min November 26, 2026

The challenge

Mossgate's build-07 has a new open port. Use the open Docker API to inspect containers. Get the private registry's S3 secret key.

What you'll learn

  • Find an exposed Docker Engine API with a full port scan
  • Map docker ps and docker inspect to their Engine API endpoints
  • Read a container's environment from Config.Env with curl and grep
  • Tell a Docker Hub pull-through mirror from a private registry
  • Lock down the Docker daemon and keep secrets out of environment variables

Skills tested

Network reconnaissanceAPI enumerationContainer securitySecret hunting

Prerequisites

  • Using curl
  • Basic grep
  • What a Docker container is

How it works

The Docker CLI is only a client: every docker command is an HTTP call to the daemon's Engine API, normally over the Unix socket /var/run/docker.sock. When the daemon is also started with -H tcp://0.0.0.0:2375 and no TLS, that API answers anyone who can reach the port, with no password. /info even carries the daemon's own warning that remote access is equivalent to root on the host.

The endpoints mirror the commands: GET /containers/json is docker ps and GET /containers/<name or id>/json is docker inspect. Inspect returns the container's full configuration, including Config.Env, every environment variable it was started with. Many images are configured entirely through the environment: the distribution registry maps REGISTRY_STORAGE_S3_* variables onto its storage settings, keys included.

Scanning for open 2375 and harvesting credentials from containers is a staple of cloud botnets (TeamTNT, Kinsing, the 2024 Commando Cat campaign), which then start miners or backdoored containers. Note that 2375 is not in nmap's default top 1000 ports: a quick scan misses it, a full -p- scan does not.

Common mistakes

  • Looking for a docker CLI. It is not installed and is not needed: curl speaks the same API.
  • Searching the container list for secrets. /containers/json shows names, images and labels, not the environment. Inspect one container to get Config.Env.
  • Taking the mirror's key. registry-mirror is listed first and has the same variable names, but REGISTRY_PROXY_REMOTEURL makes it a Docker Hub cache, writing to mossgate-hub-cache. Its secret Xr5mTb8Lh2WqZ9vNc4Kd1Js7Pf3Ga6Ye0Uo+Bt2E is not the private registry's.
  • Answering the access key ID. REGISTRY_STORAGE_S3_ACCESSKEY (AKIA5TQZRW3LN7XJMBHC) is the public half of the pair; the secret is REGISTRY_STORAGE_S3_SECRETKEY.
  • Taking another secret. REGISTRY_HTTP_SECRET only signs upload state, and REGISTRY_PROXY_PASSWORD is the mirror's Docker Hub token.
  • Reaching for exec. POST /containers/registry/exec gets a 403 from the daemon's authorization plugin, which refuses exec and new containers. It lets every read through, and inspect is a read.

How to defend against it

  • Never expose the daemon on TCP without TLS: keep the default Unix socket, or use --tlsverify with client certificates, or reach remote hosts with DOCKER_HOST=ssh://user@host.
  • Firewall 2375 and 2376 and alert on them in network sweeps, with full-range scans.
  • Keep credentials out of environment variables: anyone who can inspect a container reads them. Prefer an IAM role (instance profile) for S3, or Docker secrets mounted as files.
  • An authorization plugin that only blocks writes is not a fix: inspect, logs and file downloads are reads, and they carry the secrets.
  • Scope storage keys to one bucket, and rotate every key a reachable daemon exposed.

Full solution

Pro and Max members unlock the complete step-by-step walkthrough.

Go Pro

Community stats

114 completions
75% success rate
M2F14M3 First blood

Related Daily Hacks

42,000+ Hackers Real labs Free
Start Hacking Free or solve today's hack, no account needed