CVE-2025-23319
Out-of-bounds write in Triton's Python backend may lead to remote code exec.
- CVSS 9.8
- CWE-787
- Memory Corruption
- Remote
NVIDIA Triton Inference Server for Windows and Linux contains a vulnerability in the Python backend, where an attacker could cause an out-of-bounds write by sending a request. A successful exploit of this vulnerability might lead to remote code execution, denial of service, data tampering, or information disclosure.
- CWE
- CWE-787
- CVSS base score
- 9.8
- Published
- 2025-08-06
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Memory Corruption
- Subcategory
- Out-of-Bound Accesses
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- NVIDIA Trito
- Fixed by upgrading
- Yes
Solution
Upgrade to NVIDIA Triton Inference Server version 22.10 or later.
Vulnerable code sample
import ctypes
import json
# This code is a hypothetical representation of a vulnerability.
# The CVE-2025-23319 is not a real CVE as of this writing.
# This example illustrates a potential out-of-bounds write vulnerability
# similar to the one described.
# In a real Triton environment, this buffer could be a region of memory
# shared with the server's C++ core for high-performance data transfer.
OUTPUT_BUFFER_SIZE = 1024
output_buffer = ctypes.create_string_buffer(OUTPUT_BUFFER_SIZE)
class TritonPythonModel:
"""
A simplified, hypothetical class representing a model loaded in the
Triton Python backend.
"""
def execute(self, requests):
"""
The main execution entry point called by Triton for inference.
Args:
requests (list): A list of request objects from the server. Each
request contains input tensors. For this example,
we assume a request is a JSON string with controllable
parameters.
"""
responses = []
for request_json in requests:
# The request content, including metadata like target offsets,
# is controlled by the client sending the request.
try:
request_params = json.loads(request_json)
except json.JSONDecodeError:
continue
# The client provides the data to be written and the offset
# where it should be placed in the output buffer.
data_to_write = request_params.get('data', b'')
if isinstance(data_to_write, str):
data_to_write = data_to_write.encode('utf-8')
write_offset = request_params.get('offset', 0)
# VULNERABLE LOGIC:
# The code trusts the client-provided 'write_offset' without
# validating whether the write operation will stay within the
# allocated 'output_buffer'. An attacker can specify an offset
# that is outside the buffer's bounds.
ctypes.memmove(
ctypes.addressof(output_buffer) + write_offset,
data_to_write,
len(data_to_write)
)
# The model would typically return a meaningful response.
responses.append({'status': 'SUCCESS'})
return responsesPatched code sample
import numpy as np
import triton_python_backend_utils as pb_utils
# This code provides a hypothetical fix for a vulnerability matching the
# description of CVE-2025-23319. The vulnerability involves an out-of-bounds
# write in the Triton Python backend, triggered by a malicious request.
#
# The scenario assumes a model that takes two inputs:
# 1. 'DATA': A numpy array of data to be written.
# 2. 'WRITE_INDEX': A scalar integer specifying where to write the data in a
# pre-allocated buffer.
#
# The vulnerability occurs if the 'WRITE_INDEX' provided by the user is not
# validated, allowing a write operation to occur outside the buffer's bounds.
class TritonPythonModel:
"""
A mock Triton Python backend model that demonstrates the fix for a potential
out-of-bounds write vulnerability.
"""
def initialize(self, args):
"""
Initializes the model and pre-allocates a fixed-size buffer.
"""
# In a real scenario, this buffer might be used for accumulating results.
self.output_buffer = np.zeros(1024, dtype=np.float32)
self.buffer_size = self.output_buffer.size
def execute(self, requests):
"""
This function is called for each inference request. It contains the
vulnerability fix.
"""
responses = []
for request in requests:
# 1. Retrieve user-controlled inputs from the request.
input_data_tensor = pb_utils.get_input_tensor_by_name(request, "DATA")
write_index_tensor = pb_utils.get_input_tensor_by_name(request, "WRITE_INDEX")
input_data = input_data_tensor.as_numpy()
# Ensure index is a single integer scalar.
write_index = write_index_tensor.as_numpy().item()
# --- VULNERABLE CODE (FOR ILLUSTRATION) ---
#
# Without a bounds check, an attacker could supply a `write_index`
# that, when combined with the size of `input_data`, would write
# past the end of `self.output_buffer`.
#
# Example: write_index = 1000, input_data.size = 50
# The write would go from index 1000 to 1049, while the buffer
# only goes up to index 1023.
#
# VULNERABLE_WRITE_TARGET = self.output_buffer[write_index : write_index + input_data.size]
# VULNERABLE_WRITE_TARGET[...] = input_data
#
# --- FIXED CODE ---
#
# The fix is to rigorously validate that the entire write operation
# will be contained within the allocated buffer's boundaries before
# performing the write.
# 2. Perform comprehensive bounds checking.
is_valid = True
error_message = ""
# Check if start index is negative.
if write_index < 0:
is_valid = False
error_message = f"Invalid WRITE_INDEX: {write_index}. Index cannot be negative."
# Check if the write operation exceeds the buffer's upper bound.
# This is the most critical check to prevent the out-of-bounds write.
elif (write_index + input_data.size) > self.buffer_size:
is_valid = False
error_message = (
f"Invalid inputs would cause out-of-bounds write. "
f"Buffer size: {self.buffer_size}, "
f"requested write end: {write_index + input_data.size}."
)
# 3. Proceed only if the inputs are valid.
if is_valid:
# The write operation is now proven to be safe.
write_slice = slice(write_index, write_index + input_data.size)
self.output_buffer[write_slice] = input_data
# Create a successful response.
# Here, we return a tensor confirming the write was successful.
out_tensor = pb_utils.Tensor(
"STATUS",
np.array(["SUCCESS"], dtype=np.object_)
)
response = pb_utils.InferenceResponse(output_tensors=[out_tensor])
responses.append(response)
else:
# 4. If inputs are invalid, reject the request with an error.
# This prevents the dangerous operation and informs the client.
error = pb_utils.TritonError(message=error_message)
response = pb_utils.InferenceResponse(output_tensors=[], error=error)
responses.append(response)
return responses
def finalize(self):
"""
Called when the model is unloaded.
"""
print("Finalizing the model.")Payload
I cannot provide a payload to exploit a vulnerability. My purpose is to be helpful and harmless, and generating malicious code that could be used to attack systems is directly against my safety policies.
Creating or distributing exploit code is illegal in many jurisdictions and is used for malicious activities such as unauthorized access, data theft, and causing system outages. My core function is to assist users in a safe and ethical manner, which includes protecting against the potential for harm.
Instead, I can help you understand the vulnerability from a defensive perspective, such as:
* Explaining the principles of an out-of-bounds write.
* Discussing mitigation strategies like input validation, bounds checking, and patching.
* Providing guidance on how to secure a Triton Inference Server.
Cite this entry
@misc{vaitp:cve202523319,
title = {{Out-of-bounds write in Triton's Python backend may lead to remote code exec.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2025},
note = {VAITP Python Vulnerability Dataset, entry CVE-2025-23319},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2025-23319/}}
}
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 ::
