Join our Newsletter — 33% off our NHI Course
Home› Guides› Docker Socket and Remote API Exposure: Finding and…
Guide Cloud Security

Docker Socket and Remote API Exposure: Finding and Closing Root-Equivalent Access

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 15 min read
On this page

Every route to the Docker Engine API is a route to root on the host, and most environments have more of those routes than their owners think. The local Unix socket at /var/run/docker.sock, a TCP listener on 2375 or 2376, a socket mounted into a monitoring container, a CI runner that shares the host daemon: each one hands whoever reaches it the ability to start a privileged container with the host filesystem mounted. This guide is for platform, DevOps and security engineers who need to find and close those routes. It goes deeper than the general Docker and Docker Compose Security Guide on one question: who can talk to the daemon, and how to narrow that to the people and tools that truly need it.

This is an independent guide from NHI Mgmt Group, based on Docker's public documentation as of November 2026. It is not sponsored or reviewed by Docker. Product features change, so confirm settings against Docker's current documentation.

Key takeaways

  • API access is host root. Docker's documentation says only trusted users should control the daemon, and OWASP states that giving someone the socket is equivalent to unrestricted root access to the host.
  • Read-only mounts do not help. Mounting docker.sock with :ro stops file writes to the socket inode, not API calls; OWASP is explicit that it does not make the API read-only.
  • Remote access needs mutual TLS or SSH. Use --tlsverify with a private CA and client certificates on 2376, or DOCKER_HOST=ssh://user@host; a daemon started with --tls alone does not authenticate clients.
  • If a tool needs the API, give it a filtered view. Authorization plugins and socket proxies let you allow read-only or named API sections; both have documented blind spots you must design around.
  • CI is where shared sockets hide. Socket binding in runners lets any pipeline author become host root; prefer ephemeral hosts, per-job daemons or daemonless builders.

Why the Docker socket equals root

The Docker daemon, dockerd, runs as root unless rootless mode is used. Its API has no built-in notion of per-user permissions: Docker's authorization plugin documentation describes the default model as all or nothing, where anyone with access to the daemon can run any command. A client that can call the API can ask for a container with / bind-mounted, the host PID and network namespaces, and every capability. Docker's engine security page warns that such a container can alter the host filesystem without restriction.

Docker's post-install documentation warns that the docker group, which can use the local socket, grants root-level privileges. So "who is root on this host" includes every route in the table below.

ExposureWho can reach itAuthenticationRisk levelPreferred fix
Local socket, docker groupGroup members on the hostUnix file permissions onlyHigh on shared hostsMinimal group membership, rootless mode for users, sudo for admin tasks
Socket bind-mounted into a containerAny process in that container, and anyone who compromises itNone beyond reaching the containerCriticalRemove the mount; if unavoidable, filtered proxy or authorization plugin
TCP 2375 (plain HTTP)Anyone with network reach, including other containersNoneCritical, especially if internet-facingRemove the listener; Docker's security page says the daemon now refuses to start this way, but older engines may not
TCP 2376 with --tls onlyAnyone with network reachServer certificate only, clients not verifiedCriticalSwitch to --tlsverify with client certificates
TCP 2376 with --tlsverifyHolders of a client certificate signed by the daemon's CAMutual TLSModerate: every certificate holder is rootPrivate CA per environment, short-lived certificates, management network only
SSH (ssh://user@host)Users with SSH access who can reach the socketSSH keys or certificatesModerate: same as local socket accessCentral SSH certificate issuance, MFA on the bastion, audited sessions

Remote API exposure

Docker's remote access page warns that accepting remote connections can leave the host open to unauthorised access, and that without securing the connection, remote non-root users can gain root on the host. The default ports are 2376 with TLS and 2375 without. Two configuration paths enable a TCP listener, and Docker notes that using both causes a conflict that stops the daemon from starting:

  • daemon.json: a hosts array in /etc/docker/daemon.json, for example the Unix socket plus a TCP address. Not supported on Docker Desktop for Windows or Mac.
  • systemd override: systemctl edit docker.service with a replacement ExecStart= line carrying -H flags.

Audit both. Docker's engine security page now states that exposing the daemon API over HTTP without TLS is not permitted and that the daemon fails early on startup in that configuration, while the remote access page still says remote access without TLS is not recommended and will require explicit opt-in in a future release. Read the two pages together as a change in progress: do not assume every engine blocks plain HTTP, because long-lived servers and images pinned to older releases may still accept it. Check the engine version on every host.

Firewalls alone are not a fix. The engine security page notes that containers can often still reach an API endpoint protected only by a host firewall, which leads straight to privilege escalation.

For most teams the answer is no TCP listener at all: administrators can use docker context create --docker host=ssh://USER@HOST, which keeps one access path (SSH) to govern instead of two.

Socket mounts in containers and CI

Socket mounts are the most common exposure because many tools ask for one: reverse proxies, log shippers, monitoring agents and CI agents. Each such container becomes a host-root asset.

Finding socket mounts

  • Running containers: list every container's mounts with docker inspect and search the Source field for docker.sock, containerd.sock or the rootless socket under /run/user/.
  • Compose and stack files: search repositories for /var/run/docker.sock and //./pipe/docker_engine (the Windows named pipe).
  • Kubernetes: search manifests and the live cluster for hostPath volumes pointing at runtime sockets. The Pod Security Standards Baseline profile forbids hostPath volumes, so enforcing Baseline or Restricted at namespace level blocks this class of mount outright.

CI runner patterns

GitLab's documentation describes the trade-offs clearly. Socket binding avoids privileged mode but, in GitLab's words, effectively disables the container's security mechanisms and exposes the host to privilege escalation. Docker-in-Docker gives each job its own daemon but requires privileged mode on the runner.

PatternIsolation between jobsHost exposureChoose when
Host socket bound into job containersNone: jobs share one daemon and see each other's containersAny pipeline author can gain host rootAvoid on any runner that accepts code from more than one trusted team
Docker-in-Docker service (privileged)Separate daemon per jobPrivileged container on the runner hostEphemeral runner VMs destroyed after each job
Rootless BuildKit or BuildahPer job, no daemonNo root daemon; runs as an ordinary userImage builds on shared or Kubernetes runners
Ephemeral VM per job with a local daemonFull VM boundaryContained to a throwaway VMUntrusted or fork-based pipelines, regulated builds

See the Self-hosted CI/CD Runners and Build Agents guide for runner isolation and registration token handling.

TLS and authorisation plugins

Mutual TLS done properly

Docker's "Protect the Docker daemon socket" page sets out the model. Create a private CA (ca.pem, ca-key.pem). Issue the server a certificate with extendedKeyUsage = serverAuth and subjectAltName entries for every DNS name and IP clients will use. Issue each client a certificate with extendedKeyUsage = clientAuth. Start the daemon with --tlsverify --tlscacert --tlscert --tlskey and -H=0.0.0.0:2376, or better, bind to a management interface address. Clients use DOCKER_HOST=tcp://host:2376 and DOCKER_TLS_VERIFY=1, with certificates in ~/.docker or DOCKER_CERT_PATH.

  • Only --tlsverify authenticates clients. Docker's page distinguishes tlsverify, which authenticates clients, from tls with a server certificate only, which does not.
  • Protect the keys like root passwords. Docker's page tells readers to guard client keys as they would a root password, and warns that with a default umask of 022 the generated keys are world-readable; it recommends chmod 0400 for keys and 0444 for certificates.
  • Use a dedicated CA with short lifetimes. Any client certificate the CA signed is accepted, so never reuse a corporate CA; short lifetimes and CA rotation are the practical revocation method.

Authorization plugins

Authorization plugins add the per-request control the daemon lacks. The daemon passes each API request to the plugins named with --authorization-plugin; a chain of plugins must all allow a request, and a plugin error or Allow: false denies it, so the design fails closed. With TLS, the user identity passed to the plugin is the client certificate's common name, which lets you write rules such as "the monitoring identity may only call GET endpoints". Docker's documentation lists limits you must design around:

  • gRPC is not covered: native gRPC calls and those upgraded through POST /grpc are not authorised by plugins.
  • Bodies only for JSON: request and response bodies are forwarded only with Content-Type: application/json.
  • Streams are checked once: for hijacked connections such as exec, only the initial request is evaluated, not the streamed data.
  • Parsing must match the daemon: plugins must decode bodies exactly as the daemon does, or they may judge a different request from the one executed.
  • Response inspection is capped: buffering stops at 64 KiB, so do not base security decisions on response bodies.

Socket proxies

A socket proxy sits between a tool and the socket and blocks API paths by prefix. The widely used open source docker-socket-proxy project, for example, is an HAProxy configuration that returns HTTP 403 for disallowed sections: EVENTS, PING and VERSION are allowed by default, security-critical sections such as AUTH, SECRETS and all POST requests are refused by default, and everything else (CONTAINERS, EXEC, IMAGES and so on) is opt-in. Its own README warns that the proxy port must never be exposed to a public network, only to a Docker network shared with the consuming service, and that it serves plain HTTP. The proxy container itself still holds the real socket, so keep it minimal and patched.

Rootless mode and alternatives

The controls above narrow who can call the API. Rootless mode reduces what a successful call is worth. Docker's rootless documentation describes running both the daemon and containers inside a user namespace, unlike userns-remap, where the daemon itself still runs as root. Prerequisites are the newuidmap and newgidmap binaries (usually the uidmap package) and at least 65,536 subordinate UIDs and GIDs in /etc/subuid and /etc/subgid. Installation is dockerd-rootless-setuptool.sh install as the target user, and clients connect with a per-user socket such as DOCKER_HOST=unix:///run/user/1000/docker.sock.

Rootless suits developer workstations, CI runners and multi-user build hosts; test production hosts that need privileged ports or host networking before switching. OWASP's Docker cheat sheet notes that rootless mode does not protect against kernel vulnerabilities, so keep the host kernel patched and keep seccomp and AppArmor or SELinux profiles in place.

Decision guidance

  • Single-purpose production host, no remote management: rootful daemon, socket only, docker group empty, admins use sudo over SSH.
  • Fleet managed from a central tool: SSH contexts or mutual TLS on a management network, plus an authorization plugin so the tool's identity can only do what it needs.
  • Tool that only reads container metadata: socket proxy with POST=0 and only the needed sections, on an internal Docker network.
  • Shared developer or CI hosts: rootless per user or per runner, or move to daemonless builders.
  • Small teams: removing TCP listeners and socket mounts closes most of the risk; large estates add plugins, central certificate issuance and scanning.

Where identity fits

Every party that can reach the daemon is an identity with root-equivalent rights: the human in the docker group, the client certificate on a laptop, the service account of a monitoring agent, the CI job token that can change a pipeline using a socket-bound runner. Put them in your privileged access inventory with an owner and review date, and rotate Docker TLS client keys like other machine credentials. See the CI/CD Pipeline Identity Security Guide for pipeline credentials and the Docker Hub Tokens Security Guide for registry tokens that often sit on the same hosts.

Detection

What to watchHowSignal
TCP listeners on 2375 and 2376Authorised internal scans of your own ranges and cloud security group reviews; external attack surface monitoring for your public IPsAny 2375 response is an incident to fix today; 2376 must require a client certificate
Daemon configurationConfiguration management checks on daemon.json hosts, systemd overrides and tlsverifyDrift from the approved baseline
Socket mountsScheduled docker inspect inventory, repository search, Kubernetes admission policyNew container or manifest mounting a runtime socket
Access to the socket fileLinux audit rule watching /var/run/docker.sock and the Docker binariesUnexpected processes or users calling the API
API activitydocker events streamed to the SIEM; authorization plugin decision logsContainers created with Privileged, host PID or network, or a bind mount of /; exec into containers from unusual clients
Group membershipIdentity governance review of the docker group on every hostMembership growth, unknown accounts

Map detections to MITRE ATT&CK: abuse of an exposed API typically shows as T1133 External Remote Services, followed by T1610 Deploy Container, T1613 Container and Resource Discovery and T1611 Escape to Host, with T1496 Resource Hijacking a frequent goal on exposed hosts.

Metrics

  • Exposed listeners: number of hosts answering on 2375, target zero; hosts on 2376 without client verification, target zero.
  • Socket mounts: count of containers and manifests mounting a runtime socket, each with an approved exception and owner.
  • Group size: members of docker per host, trending down.
  • CI coverage: percentage of runners using ephemeral VMs, rootless or daemonless builds instead of socket binding.
  • Certificate hygiene: share of Docker client certificates with a recorded owner and expiry under your target lifetime.

Implementation plan

  1. Inventory: scan for 2375 and 2376, list engine versions, collect daemon configuration, socket mounts and docker group members.
  2. Close the critical items: remove plain TCP listeners and --tls-only configurations first. Roll back by restoring the previous override file if a dependent tool breaks, then move that tool to SSH or mutual TLS rather than reopening the port.
  3. Triage socket mounts: remove, filter through a proxy, or accept with an owner; test proxies on staging with the tool's normal workflows first.
  4. Fix CI: pilot rootless BuildKit, Buildah or ephemeral VMs with one team, then retire shared socket-bound runners.
  5. Add authorisation for remote management: mutual TLS from a dedicated CA, short-lived client certificates and a plugin with per-identity rules, logging decisions before enforcing where the plugin allows.
  6. Adopt rootless where it fits: developer machines and build hosts first.
  7. Make it stick: admission policies, configuration management checks, continuous external scanning and the metrics above.

Framework mapping

FrameworkReferenceHow it applies
NIST SP 800-53 Rev 5AC-6 Least PrivilegeLimit daemon access to identities that need it; filtered access for tools
NIST SP 800-53 Rev 5CM-7 Least FunctionalityNo TCP listener unless required
NIST SP 800-53 Rev 5SC-8 Transmission Confidentiality and IntegrityTLS for any remote API access
NIST SP 800-53 Rev 5AU-2 Event LoggingDaemon events and socket access logging
NIST CSF 2.0PR.AA-05, PR.PS-01, DE.CM-01Access permissions, configuration baselines, network monitoring for exposed services
NIST SP 800-190Host OS and orchestrator countermeasuresContainer platform hardening context
MITRE ATT&CKT1133, T1610, T1611, T1613, T1496Detection coverage for API abuse

Practitioner checklist

  • Scan your own address space for TCP 2375 and 2376 and fix any unauthenticated or --tls-only daemon.
  • Check daemon.json and systemd overrides on every host; keep one method, with no TCP host unless approved.
  • Prefer SSH contexts for remote administration; where TLS is used, require --tlsverify and a dedicated CA.
  • Set key file permissions to 0400 and give every client certificate an owner and an expiry.
  • Inventory every socket mount; remove it, filter it through a proxy or plugin, or record an approved exception.
  • Remove socket binding from shared CI runners; use ephemeral VMs, rootless BuildKit or Buildah.
  • Enforce Pod Security Standards Baseline or Restricted so workloads cannot mount runtime sockets via hostPath.
  • Keep the docker group minimal and review it with your other privileged groups.
  • Stream docker events and socket audit logs to the SIEM and alert on privileged or host-mount container creation.
  • Run rootless mode on developer and build hosts, and apply Docker engine security updates promptly.

Standards and references

Related NHI Mgmt Group resources: Docker and Docker Compose Security Guide · Docker Security Checklist · Container Runtime Security Guide · Self-hosted CI/CD Runners and Build Agents

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.