CVE-2026-93348
Code injection via newline in model_type config enables RCE during model loading.
- CVSS 8.6
- CWE-94
- Input Validation and Sanitization
- Remote
Unsloth Zoo versions 2025.9.9 before 2026.8.14, as implemented in Unsloth 2025.9.9 through 2026.8.19, contains a code injection vulnerability in the model-loading compile path where the get_transformers_model_type() function in hf_utils.py collects model_type values from nested model configurations without enforcing a character allowlist, allowing newlines and arbitrary Python source to survive normalization. Attackers can embed a newline in a nested model_type value within a malicious model's config.json to terminate the generated import statement and execute arbitrary Python code via exec() in unsloth_compile_transformers(), achieving remote code execution as the loading user when the model is loaded for training or inference.
- CWE
- CWE-94
- CVSS base score
- 8.6
- Published
- 2026-09-28
- OWASP
- A03 Injection
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- Unsloth
- Fixed by upgrading
- Yes
Solution
Upgrade Unsloth Zoo to version 2026.8.20 or later, which patches the code‑injection flaw.
Vulnerable code sample
import json
import os
def unsloth_compile_transformers(model_dir: str):
config_path = os.path.join(model_dir, "config.json")
with open(config_path, "r", encoding="utf-8") as f:
cfg = json.load(f)
# VULNERABLE: unsanitized model_type used in exec
model_type = get_transformers_model_type(cfg)
import_stmt = f"from transformers import {model_type}"
exec(import_stmt) # noqa: S102
def get_transformers_model_type(cfg: dict) -> str:
"""
Recursively collect 'model_type' from nested config sections.
"""
if isinstance(cfg, dict):
for key, value in cfg.items():
if key == "model_type":
return value
result = get_transformers_model_type(value)
if result:
return result
elif isinstance(cfg, list):
for item in cfg:
result = get_transformers_model_type(item)
if result:
return result
return "AutoModel"Patched code sample
import json
import os
import re
_ALLOWED_MODEL_TYPE = re.compile(r"^[A-Za-z0-9_]+$")
def unsloth_compile_transformers(model_dir: str):
config_path = os.path.join(model_dir, "config.json")
with open(config_path, "r", encoding="utf-8") as f:
cfg = json.load(f)
# FIX: validate model_type before exec
model_type = get_transformers_model_type(cfg)
if not _ALLOWED_MODEL_TYPE.fullmatch(model_type):
raise ValueError("Invalid model_type detected")
import_stmt = f"from transformers import {model_type}"
exec(import_stmt) # noqa: S102
def get_transformers_model_type(cfg: dict) -> str:
"""
Recursively collect 'model_type' from nested config sections.
"""
if isinstance(cfg, dict):
for key, value in cfg.items():
if key == "model_type":
return value
result = get_transformers_model_type(value)
if result:
return result
elif isinstance(cfg, list):
for item in cfg:
result = get_transformers_model_type(item)
if result:
return result
return "AutoModel"Cite this entry
@misc{vaitp:cve202693348,
title = {{Code injection via newline in model_type config enables RCE during model loading.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-93348},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-93348/}}
}
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 ::
