VAITP Dataset

← Back to the dataset

CVE-2026-41523

vLLM RCE via malicious model due to an assert bypass in optimized mode.

  • CVSS 7.5
  • CWE-94
  • Design Defects
  • Remote

vLLM is an inference and serving engine for large language models (LLMs). Prior to 0.22.0, an assert-based security check in vLLM's activation function loading allows any unauthenticated attacker to achieve arbitrary code execution on the server by publishing a malicious HuggingFace model, when vLLM runs in Python optimized mode (python -O or PYTHONOPTIMIZE=1). This vulnerability is fixed in 0.22.0.

CVSS base score
7.5
Published
2026-06-22
OWASP
A08 Software and Data Integrity Failures
Orthogonal defect classification
Checking
Code defect classification
Incorrect Check
Category
Design Defects
Subcategory
Insecure Parsing or Deserialization
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
vLLM
Fixed by upgrading
Yes

Solution

Upgrade vLLM to version 0.22.0 or later.

Vulnerable code sample

import os

# This is a simplified representation of the vulnerable code pattern.
# In the actual vLLM codebase, this logic was part of the activation function loading mechanism.

# A list of known, safe activation functions.
ALLOWED_ACTIVATIONS = ["gelu", "relu", "silu"]

def get_activation(activation_name: str):
    """
    Loads an "activation function" from a model's configuration.

    This function contains a security check using `assert`. When Python is run in
    optimized mode (`python -O`), `assert` statements are removed, bypassing the check
    and allowing the untrusted `activation_name` string to be processed by a
    dangerous function like `eval`, leading to arbitrary code execution.
    """
    
    # VULNERABLE SECURITY CHECK: This line is ignored in optimized mode.
    assert activation_name in ALLOWED_ACTIVATIONS, "Disallowed activation function."

    # If the assert is bypassed, this `eval` call can execute arbitrary code.
    # The attacker provides a malicious string as the 'activation_name' in their
    # model's configuration file.
    # Example malicious string: "__import__('os').system('echo pwned > /tmp/pwned')"
    return eval(activation_name)

Patched code sample

import importlib
from typing import Callable


def get_activation_function(name: str) -> Callable:
    """
    Loads an activation function specified by its full module path.

    This fixed version replaces an `assert` statement with a proper
    conditional check to ensure that even in Python's optimized mode,
    only modules from a trusted path (e.g., 'vllm.') can be loaded.
    This prevents an attacker from specifying a malicious module
    (e.g., 'os.system') in a model's configuration file.
    """
    module_path, function_name = name.rsplit(".", 1)

    # The Fix: Replaced `assert module_path.startswith("vllm.")` with an
    # `if` statement that raises an exception. This check is not disabled
    # by the Python optimizer (`python -O`).
    if not module_path.startswith("vllm."):
        raise ValueError(
            f"Activation function's module must be a submodule of 'vllm'. "
            f"Got '{module_path}'."
        )

    module = importlib.import_module(module_path)
    return getattr(module, function_name)

Payload

import os

os.system("touch /tmp/pwned")

def exploit_function(x):
    return x

Cite this entry

@misc{vaitp:cve202641523,
  title        = {{vLLM RCE via malicious model due to an assert bypass in optimized mode.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-41523},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-41523/}}
}
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 ::