VAITP Dataset

← Back to the dataset

CVE-2026-118618

Ultralytics parse_model RCE: unsanitized input leads to code injection.

  • CVSS 7.8
  • CWE-94
  • Input Validation and Sanitization
  • Remote

Ultralytics parse_model Code Injection Remote Code Execution Vulnerability. This vulnerability allows remote attackers to execute arbitrary code on affected installations of Ultralytics. User interaction is required to exploit this vulnerability in that the target must visit a malicious page or open a malicious file. The specific flaw exists within the parse_model function. The issue results from the lack of proper validation of a user-supplied string before using it to execute Python code. An attacker can leverage this vulnerability to execute code in the context of the current user. Was ZDI-CAN-30121.

CVSS base score
7.8
Published
2026-10-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
Ultralytics
Fixed by upgrading
Yes

Solution

Upgrade Ultralytics to version 8.2.0 or later, which patches the parse_model code‑injection RCE vulnerability (ZDI‑CAN‑30121).

Vulnerable code sample

import yaml

def parse_model(model_cfg_path: str) -> dict:
    """
    Load a YOLO model configuration file and parse the ``model`` section.
    The original implementation uses ``eval`` on a user‑supplied string,
    which allows arbitrary code execution.
    """
    with open(model_cfg_path, 'r') as f:
        cfg = yaml.safe_load(f)

    model_section = cfg.get('model', {})
    layers = model_section.get('layers', [])

    parsed = {}
    for i, layer in enumerate(layers):
        # VULNERABLE: uses eval on untrusted string
        layer_type = eval(layer.get('type', ''))
        parsed[i] = {'type': layer_type, 'params': layer.get('params', {})}
    return parsed

Patched code sample

import yaml
import ast

def parse_model(model_cfg_path: str) -> dict:
    """
    Load a YOLO model configuration file and parse the ``model`` section.
    The fix replaces ``eval`` with ``ast.literal_eval`` to prevent code execution.
    """
    with open(model_cfg_path, 'r') as f:
        cfg = yaml.safe_load(f)

    model_section = cfg.get('model', {})
    layers = model_section.get('layers', [])

    parsed = {}
    for i, layer in enumerate(layers):
        # FIX: replace eval with safe literal evaluation
        layer_type = ast.literal_eval(layer.get('type', "''"))
        parsed[i] = {'type': layer_type, 'params': layer.get('params', {})}
    return parsed

Cite this entry

@misc{vaitp:cve2026118618,
  title        = {{Ultralytics parse_model RCE: unsanitized input leads to code injection.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-118618},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-118618/}}
}

Download this entry as JSON Download the whole dataset

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 ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.