Hostile Inference: Exploiting Docker Model Runner for Container Escapes
Local LLM inference is seeing adoption in default developer workflows, and the tooling that serve 2026-11-18 17:23:52 Author: www.thezdi.com(查看原文) 阅读量:4 收藏

Local LLM inference is seeing adoption in default developer workflows, and the tooling that serves those models now ships inside products developers already trust. One of those is Docker Model Runner (DMR), the feature in Docker Desktop that pulls, runs, and serves models locally. In November 2025, we reported ZDI-26-150 / CVE-2026-28400, a denial-of-service (on macOS) stemming from an unauthenticated argument-injection vulnerability in DMR. A container created with the default set of privileges could overwrite and corrupt the Docker Desktop VM’s data disk. Further analysis, under non-default configurations, turned the same primitive into arbitrary code execution on the host, on both macOS and Windows.

In this post, we walk through the full chain: the argument-injection primitive, the host file read/write foothold it grants, how we take partial control of what gets written, and the payoff that turns a constrained file write into arbitrary code execution on the host through Docker Extensions. We then cover two further escapes we found along the way: one from an overly permissive Seatbelt sandbox configuration on macOS, and one that pivots the WSL2 VM-to-host boundary through Docker Extensions.

Background: Docker Model Runner and the host boundary

Docker Desktop helps run Docker containers on macOS, Windows, and Linux. Docker Desktop for Windows with Windows containers and Docker Desktop for Linux are out of scope for this blog. Since macOS and Windows don’t come with a Linux kernel to run Linux containers, Docker Desktop ships a LinuxKit VM that hosts the container runtime; on macOS the VM runs using the Apple Virtualization Framework, while on Windows it runs under WSL2 by default.

Linux containers and the Docker Engine components (runc, containerd, dockerd) run in the Linux VM. Bridging the gap between the host OS and the VM is a daemon called Docker Backend: com.docker.backend (macOS) or com.docker.backend.exe (Windows). This process is responsible for managing the execution environment and brokering all inter-process communication (IPC) across the VM–OS boundary.

DMR lets users pull, run, and serve models over OpenAI-compatible APIs using the same idioms as running containers (docker model pull, docker model run). Models are distributed as OCI artifacts through OCI-compliant registries and stored on the host. At the time of our research, DMR would create an instance of llama.cpp’s llama-server for inference tasks. DMR is compiled into the Docker Backend. The detail that makes this interesting: on macOS and Windows the inference process does not run inside the VM; it runs on the host, as a child of the Docker Backend, with the privileges of the user running Docker Desktop. Because models are, correctly, treated as untrusted input, the inference process is wrapped in an OS-native sandbox using Seatbelt on macOS and Job Objects on Windows. These are not equivalent boundaries, and that difference carries much of the weight on Windows, as we will see in a bit.

The DMR REST API is unauthenticated and reachable from any container at the container-internal DNS name model-runner.docker.internal over HTTP. The question we set out to answer was whether a stock container, created with no additional capabilities, flags, mounts, or privileges, could lead to a container-to-host compromise.

The Primitive: Argument Injection in _configure

We refer throughout to the DMR repository at docker/model-runner@38a800. The API is split by two prefixes, both served over model-runner.docker.internal:

Backed by the ConfigureRequest struct, the _configure endpoint accepts two JSON properties whose values are appended as command-line arguments for llama-server. It calls the “Configure” method of the scheduler.

[1] - The body of the incoming /engines/_configure request is unmarshalled.

[2.1 & 2.2] - If the body of the POST request has runtime-flags populated, the value is saved to runtimeFlags as-is. If the body has raw-runtime-flags populated, the value is tokenized through shellwords.Parse().

[3 & 4] - runnerConfig stores the inference server`s backend configuration.

[5] - The POST request's model property is used to fetch the model ID for which the config will be modified.

[6] - setRunnerConfig persists the modified configuration per model and mode (embedding or non-embedding). At this point, the altered configuration will be applied to the runner's next spawn.

Using the chat-completions endpoint /v1/chat/completions, we can load the model that would run the inference server with the altered configuration. Let's see how the arguments propagate.

[4] - If an existing runner for {backend, modelID, mode} is alive, it is reused as-is. Altered configuration is ignored if a runner already exists.

[5] - Otherwise, the persisted flags from _configure endpoint are retrieved into runnerConfig.

[6] - The runner is created via the package-level run(...) in pkg/scheduling/runner.go, passing the retrieved configuration.

[7] - run() calls backend.Run() inside a goroutine, populated with the slot's Unix socket path, the model ID, the request-deduced mode, and the attacker-controlled runnerConfig retrieved from _configure. backend.Run() invokes the inference.Backend interface; the registered and default implementation is llama.cpp`s llama-server.

[8, 8.1] - GetArgs constructs llama-server’s final command line: hardcoded performance flags, model path, socket host, mode, context-size arguments, followed by the caller-supplied runtime flags appended as-is.

This sounds quite promising – a container created with default privileges can modify arguments of a process that runs on the host. There have been memory-corruption bugs in llama.cpp that could be triggered by malicious GGUF models. Using the DMR REST API, we can pull and load arbitrary GGUF models. So, an obvious next step would be to examine the llama-server codebase for exploitable bugs that result in arbitrary code execution, – either through malicious GGUF models or through the argument injection primitive we already have. llama-server offers no flag that executes code on its own. The useful arguments are the ones that touch the filesystem, and whether they are really useful at all depends on what the OS sandbox around llama-server permits. So, we examine the llama-server flags that result in file operations.

The Foothold: Reading and Writing Host Files

Three llama-server flags are file-operation sinks, and llama-server is the same binary on both platforms, so they behave identically. What differs is which paths the surrounding sandbox leaves reachable.

• --grammar-file: reads a file as a GBNF (GGML Backus-Naur Form) grammar; parsing errors log the file’s contents.

• --chat-template-file: reads a file as a Jinja2 chat template; its content can be logged by combining it with --verbose.

• --log-file: writes inference logs to the specified path.

macOS: Seatbelt profile

Since Docker Desktop 4.46.0, llama-server on macOS is launched via sandbox-exec using a Seatbelt profile. The profile opens with (allow default), a deliberate choice that requires enumerating the DYLD, Mach, IOKit, and Darwin surfaces llama-server depends on, and then denying known-dangerous operations.

From a process standpoint, the profile is heavily locked down, so we focused on the file operations it permits, which are:

• Reads under ~/.docker/models, ~/Library/Containers/com.docker.docker/Data, and WORKDIR (which resolves to that same Data directory).

• Writes to /dev/null, and under /private/var/, ~/Library/Containers/com.docker.docker/Data, and WORKDIR.

The directory ~/Library/Containers/com.docker.docker/Data is where Docker Desktop stores its logs, the Unix sockets for VM-host IPC, Docker Extension assets, and the data disk at vms/0/data/Docker.raw. Since the Seatbelt profile allows file reads and writes in paths under the Data tree, we can point the file read flags (--grammar-file, --chat-template-file) to read Docker Desktop logs, which have many times been found to contain credentials. This is one interesting find.

Another possibility is to point --log-file to the path of the disk located at vms/0/data/Docker.raw to overwrite it with llama-server logs. This disk contains every container, image, volume, and image build cache for the current user running Docker Desktop. The following requests from a Docker container result in the data disk being overwritten:

Windows: Job Objects

On Windows, DMR sandboxes llama-server using a Windows Job Object, built on go-winjob, with a configuration that blocks clipboard read and write, disables outgoing network traffic, prevents desktop switching and system-parameter changes, and terminates the process on unhandled exceptions.

Job Objects are used to constrain memory, CPU, process count, and process lifetime. They impose no filesystem restrictions at all, other than what's allowed by the user's privileges. The sandboxed llama-server runs with the same filesystem access as the Docker Desktop user, so the file-operation flags give arbitrary read and write access, bounded only by the user's DACL.

One will immediately notice that the username is required to construct paths of interest. DMR decides where llama-server runs by comparing the digest of its bundled binary with the Docker Hub image docker/docker-model-backend-llamacpp:latest. On a mismatch, the image from Docker Hub is pulled and the binary and DLLs are extracted to %USERPROFILE%\.docker\bin\; otherwise llama-server runs from %PROGRAMFILES%\Docker\Docker\resources\model-runner\bin. The working directory is therefore not deterministic, and path traversal into the user’s data directories is unstable. To write to %APPDATA%, %LOCALAPPDATA%, or %USERPROFILE% reliably, we need the username. We found two ways to leak it from a container without any user interaction.

The first is a UNC path. The --log-file flag accepts a UNC path, and the SMB session-setup negotiation against an attacker-controlled SMB server discloses the Docker Desktop user’s username in cleartext (and yields a capturable Net-NTLMv2 value as a bonus, which could be relayed or cracked, though the chain only needs the username). During enumeration we found the following flags also accept UNC paths: --lora, --control-vector, --model, --grammar-file, --json-schema-file, --mmproj, --api-key-file, --chat-template-file, and --model-draft.

The second is simpler and entirely local. Passing an invalid argument or value makes llama-server exit with an error, and the username appears in the error log along with the host paths it prints.

With the username in hand, the Windows write becomes deterministic; anywhere the Docker Desktop user can read and write, from a container created with default capabilities. At this point we have, from a stock container on either platform, host file read and a write whose destination we control. We do not yet control the file’s contents, and we do not have arbitrary code execution. Both come next.

The Payload: Controlling Log Contents

--log-file writes llama-server’s own log output, not arbitrary bytes of our choosing, so the write is only as useful as our control over what llama-server logs. When llama-server loads a GGUF model, it serializes server info, the model path, and then the model metadata. GGUF models store hyperparameters, names, descriptions, and chat templates as key-value pairs inside a single file. Examining the llama-server logging paths, we found multiple unsanitized sinks that let an attacker place arbitrary content into the logs:

• GGUF metadata key names.

•  GGUF metadata values, for example general.name.

•  The chat template stored in the metadata key tokenizer.chat_template.

This list is not exhaustive, and using it requires the content to be in a GGUF model, which we can pull via /models/create. Two llama-server arguments make log pollution independent of a crafted model: --verbose, which logs system and user prompts along with responses (and the chat-completions endpoint is reachable from a container, so we simply send our content in the prompt and let llama-server log it for us), and --override-kv, which injects or overwrites GGUF metadata key-value pairs at runtime. Chained with the argument-injection primitive, --override-kv is a direct path to writing attacker-crafted metadata into the inference logs.

These sinks are a property of llama-server, not the host OS, so the technique carries across platforms unchanged. After this step, we control the destination path (within each platform’s cap), the file name, and, deterministically, a meaningful portion of the content. The remaining question is where a partially-controlled file write becomes arbitrary code execution. The answer is Docker Extensions.

The Payoff: Arbitrary Code Execution via Docker Extensions

Docker Extensions let third-party tools plug into Docker Desktop. They consist of a renderer that runs inside Docker Desktop’s Electron UI, an optional container backend, and executables that can be run on the host (as required by the Docker Extension). For a deeper treatment of the extension attack surface, we recommend Orange Cyberdefense’s write-up, “An Offensive Look at Docker Desktop Extensions,” by Leon Jacobs. Docker Desktop’s UI runs Electron with Node.js integration disabled and with context isolation and sandboxing enabled. Extensions have been leveraged before as a route to arbitrary code execution (e.g., CVE-2024-8695, CVE-2024-8696, ZDI-24-1019).

The renderer exposes the Docker Extensions SDK. A ddClient object offers methods for listing containers and images, navigating the Docker Desktop UI, and more. Two are relevant to this chain:

•  ddClient.docker.cli.exec(cmd, [args...]): runs the Docker CLI on the host with arbitrary arguments, including powerful flags such as --privileged, volume mounts, --cap-add, --pid, --ipc, --net, and --device

•  ddClient.extension.host.cli.exec(cmd, [args...]): invokes an executable located in the extension’s dedicated host/ directory on the host, unsandboxed.

Because extensions can trigger privileged host operations by design, their assets (web resources and host executables) are valuable. Furthermore, they are stored on the host at predictable paths. On macOS, those paths sit inside the Seatbelt-permitted Data subtree, which makes them writable via the --log-file primitive. On Windows they live under %APPDATA%\Docker\extensions\, which is why the username leak above matters.

To drop an executable rather than only overwrite a renderer, we also need the host filesystem to be reachable from an additional helper container that is launched by the Extension frontend. By default, Docker Desktop shares host directories into the VM with the privileges of the user running Docker Desktop: on macOS over VirtioFS (/Users, /Volumes, /private, /tmp, /var/folders), and on Windows over WSL2’s 9P protocol, with host drives mounted under /mnt.

In both cases, a container with the VM filesystem bind-mounted can write directly into the Extensions assets directory. This design choice is also why a container that has escaped to the Docker Desktop VM can reach the host filesystem as the current user running Docker Desktop.

Proof of Concept

The PoC has the following prerequisites:

1.    A Docker Extension is installed

2.    The user runs a malicious image or a container gets compromised

3.    The user opens the extension`s UI after running it

Here’s the GGUF Payload:

1.  Stage 0, from the container: on Windows, first leak the Docker Desktop username, either by pointing a UNC --log-file at an attacker-controlled SMB server or by forcing llama-server to exit on a rejected argument and then reading the username from its error log. In either event, the next step is to use the file-read primitive to read the Docker Desktop logs and enumerate the names of installed extensions; on Windows this read requires the leaked username, while on macOS all logs can be found within the Data subtree.

2.  Stage 1, from the container: pull the crafted GGUF whose general.name is a JS payload that will be rendered in the extension UI. On Windows, use the username from Stage 0 to construct the %APPDATA% extension path. Point --log-file at each installed extension’s index.html and trigger inference. When the chat completion runs, llama-server logs the metadata value, overwriting the extension’s index.html on the host with the inference log containing the JS payload.

3.  Stage 2, from the host: when the user opens the extension, the renderer parses the overwritten index.html and executes the injected JS. It calls ddClient.docker.cli.exec to create a helper container that mounts the VM root at /hostOS and, through the VirtioFS or 9P mount, writes an executable into the extension’s host/ directory (calc.sh on macOS, calc.bat on Windows). It then calls ddClient.extension.host.cli.exec to run the dropped executable on the host, with the Docker Desktop user’s privileges. No sandbox profile gates arbitrary code execution through the extension UI.

Here’s the PoC in action on macOS

In Stage 2 of the above chain, we use two ddClient calls – one to drop an executable to the host directory, and a second to invoke it. We found that it was possible to achieve arbitrary code execution on the host using a single ddClient call that uses only the Docker CLI.

The llama-server executable is generally run from the user's home directory, as DMR ships an update mechanism that downloads the latest binaries from Docker Hub into ~/.docker/bin/inference/. Our question is: what happens if the binary itself is replaced with an executable script and then invoked through the chat-completions API?

The weakness lies in the Seatbelt profile: com.docker.llama-server’s profile does not deny access to the launchservicesd Mach service. Seatbelt profiles are inherited across standard fork/exec, but macOS offers an alternate execution path through LaunchServices via the /usr/bin/open executable.

When a sandboxed process invokes open, execution is delegated to launchd, and because launchd becomes the parent, the target spawns as a new process, free of the caller’s sandbox restrictions.

Proof of Concept

Simulating a container with access to the Docker Desktop VM via a bind mount (the same VirtioFS sharing described above), we overwrite ~/.docker/bin/inference/com.docker.llama-server with a shell script. The container then calls the chat-completions API, which triggers the Docker Backend to launch our script under the Seatbelt profile.

The script creates an application bundle under /private/var/tmp (a location the profile permits writing to), containing an app that spawns a reverse shell, and then runs open -a /private/var/tmp/poc.app followed by open -a Calculator. Both calls are delegated to LaunchServices and forwarded to launchd, which spawns the apps unsandboxed. The Seatbelt profile is not inherited across that boundary, although the standard macOS protections such as TCC and Gatekeeper still hold.

Going Further: Escaping the WSL2 VM via Docker Extensions (ZDI-26-258)

On Windows, Docker Desktop uses WSL2 as the default backend. For readers interested in WSL2 VM-escape techniques that are structurally independent of DMR, our companion write-up documents several; here we share the first Docker Desktop WSL2 VM-to-host technique we found that pivots on Docker Extensions.

At Pwn2Own Vancouver 2024, STAR Labs researchers demonstrated a Docker Desktop container escape on Ubuntu (ZDI-24-1019 / CVE-2024-6222, fixed in 4.29.0), using an io_uring use-after-free to escape from the container into the VM and Docker Extensions to pivot from the VM to the host.

They installed an arbitrary extension via the extension-manager socket and navigated the UI via a socket named backend.sock to invoke a host binary. In response, Docker disabled io_uring and later enabled a flag in version 4.31.0 to only allow installation of extensions distributed through the Docker Marketplace.

In April 2025 we found that if the Docker Desktop VM is compromised, the “Allow only extensions distributed through the Docker Marketplace” flag could be toggled from the VM itself through the same backend socket. The backend socket is located at /run/host-services/backend.sock in the VM. It exposes an /app/settings API that answers both GET and POST, where GET returns the current settings and POST modifies them.

Flipping onlyMarketPlaceExtensions re-enabled arbitrary extension installation, which in turn leads to arbitrary code execution on the host. We reported our findings as ZDI-26-258 to Docker, to which Docker responded that the attack scenario falls outside of their threat model since the container-to-VM escape prerequisite is privileged in the first place. Hence, if you have a container-to-VM escape for WSL2 or an exposed Docker API (e.g., CVE-2025-9074) or a way to mount Docker sockets, you can use such VM-to-host escapes to achieve arbitrary code execution on the host.

Vendor Response and Patches

For ZDI-26-150, the fix came in three stages.

1. 0699420a (#482, 2025-12-05) removed runtime flags from POST /engines/_configure entirely, replacing them with structured backend-specific configuration.

2. 41dd3f13 (#518, 2025-12-16) reintroduced runtime flags but added validatePathSafety, which rejects any flag or value containing `/` or `\` - fixing the path operations.

3. 9acf1ed9 (#601, 2026-02-09) layered on a strict per-backend allowlist, so only safe flags such as --threads or --ctx-size pass validation.

All three shipped in DMR v1.0.16 with a follow-up hardening commit 78504107 (#667) removing --trust-remote-code, an allowlisted flag that could allow models in vLLM to escape the container. Docker Desktop users received the fixed DMR via version 4.61.0 and later.

For ZDI-26-451, commit 98038869 modified the Seatbelt profile to deny Mach service lookups for com.apple.launchservicesd and com.apple.coreservices.launchservicesd, blocking the LaunchServices path.

Disclosure Timeline

ZDI-26-150 (Docker Desktop for Mac Docker Model Runner Exposed Dangerous Function Denial-of-Service Vulnerability):

•  2025-11-05: Reported to the vendor.

•  2026-03-03: Docker confirmed the fix (CVE-2026-28400, GHSA-m456-c56c-hh5c).

•  2026-03-03: Coordinated public release of the advisory.

ZDI-26-451 (Docker Desktop for macOS Inference Server Permissive Allow List Sandbox Escape Vulnerability):

•  2026-02-25: Reported to the vendor.

•  2026-02-27: Docker merged the tightened Seatbelt profile.

•  2026-07-23: Coordinated public release of the advisory.

Conclusion

Local inference is only going to become more common in developer environments as open-weight models and the hardware to run them improve. The boundaries developers tend to trust (container isolation, sandboxed inference, and marketplace-only extensions) do not automatically extend to the attack paths that arrive with a local-AI stack. A careful audit of deliberate design choices is essential to identify potential vulnerabilities before the most critical components of the supply chain are compromised.

You can find me on Twitter at @_niteshsurana, and follow the team on Twitter, Mastodon, LinkedIn, or Bluesky for the latest in exploit techniques and security patches.


文章来源: https://www.thezdi.com/blog/2026/11/17/hostile-inference-exploiting-docker-model-runner-for-container-escapes
如有侵权请联系:admin#unsafe.sh