CVE-2025-63397
Improper validation of Python sequences in OneFlow v0.9.0 causes a segfault.
- CVSS 6.5
- CWE-20
- Input Validation and Sanitization
- Local
Improper input validation in OneFlow v0.9.0 allows attackers to cause a segmentation fault via adding a Python sequence to the native code during broadcasting/type conversion.
- CWE
- CWE-20
- CVSS base score
- 6.5
- Published
- 2025-11-10
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Local
- Impact
- Denial of Service (DoS)
- Affected component
- OneFlow
- Fixed by upgrading
- Yes
Solution
Upgrade to OneFlow v0.9.2 or later.
Vulnerable code sample
import oneflow
# This code represents a hypothetical vulnerable state before a fix.
# It assumes a vulnerable version of OneFlow (e.g., v0.9.0) is installed.
# 1. Create a valid OneFlow tensor.
tensor_a = oneflow.ones((2, 2), dtype=oneflow.int32)
# 2. Create a malformed Python sequence (a ragged list).
# The native code expects a uniform shape (e.g., 2x2), but this list is not.
malformed_python_sequence = [[1, 2], [3]]
# 3. Trigger the vulnerability.
# The addition operation causes an implicit conversion of the Python sequence
# to a native tensor. The lack of proper input validation would lead the C++
# backend to read out-of-bounds memory when processing the second, shorter
# sublist, resulting in a segmentation fault and crashing the program.
result = tensor_a + malformed_python_sequencePatched code sample
import numbers
class FixedOneFlowTensor:
"""
A mock Tensor class representing a fixed version of a OneFlow tensor.
The fix for the described vulnerability is implemented in the __add__ method.
"""
def __init__(self, data):
if not isinstance(data, list) or not all(isinstance(x, numbers.Number) for x in data):
raise TypeError("Tensor data must be a list of numbers.")
self.data = data
self.shape = (len(data),)
def __repr__(self):
return f"FixedOneFlowTensor({self.data})"
def __add__(self, other):
"""
This method demonstrates the fix for CVE-2025-63397.
The vulnerability was improper input validation. The fix involves
explicitly checking for Python sequences and converting them to a
tensor object before they can be passed to the underlying
native code responsible for the operation.
"""
processed_other = None
# --- START OF THE FIX ---
if isinstance(other, (list, tuple)):
# 1. VALIDATION: Identify if the operand is a Python sequence.
# This check was missing in the vulnerable version.
try:
# 2. TYPE CONVERSION: Convert the sequence to a tensor object.
# This ensures the native code receives a valid, expected type.
processed_other = FixedOneFlowTensor(list(other))
except TypeError as e:
raise TypeError(f"Could not convert sequence to Tensor: {e}")
elif isinstance(other, FixedOneFlowTensor):
# If it's already a tensor, use it directly.
processed_other = other
else:
# 3. FAIL-SAFE: Raise a clean Python error for other unsupported types
# instead of allowing a pass-through that would cause a crash.
raise TypeError(
f"Unsupported operand type(s) for +: 'FixedOneFlowTensor' and '{type(other).__name__}'"
)
# --- END OF THE FIX ---
# The following represents the native operation that would now safely execute.
if self.shape != processed_other.shape:
# This simulates a broadcasting error check in the native code.
raise ValueError(f"Shape mismatch: {self.shape} vs {processed_other.shape}")
result_data = [x + y for x, y in zip(self.data, processed_other.data)]
return FixedOneFlowTensor(result_data)
# --- Demonstration of the fixed code in action ---
# 1. A tensor object representing a native data structure in OneFlow.
tensor_object = FixedOneFlowTensor([100, 200, 300])
# 2. A standard Python list. In the vulnerable version, using this in an
# operation would pass it directly to native code, causing a segfault.
python_sequence = [1, 2, 3]
# 3. With the fix, the __add__ method correctly validates and converts the
# 'python_sequence' into a 'FixedOneFlowTensor' before the operation.
# The code now executes safely without crashing.
result = tensor_object + python_sequence
# The 'result' is a valid tensor, proving the fix was successful.
# To see the output, you could uncomment the following line:
# print(result)Payload
import oneflow as flow
vulnerable_tensor = flow.tensor([1, 2, 3])
python_list_input = [4, 5, 6]
# This operation triggers the segmentation fault
result = vulnerable_tensor + python_list_input
Cite this entry
@misc{vaitp:cve202563397,
title = {{Improper validation of Python sequences in OneFlow v0.9.0 causes a segfault.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2025},
note = {VAITP Python Vulnerability Dataset, entry CVE-2025-63397},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2025-63397/}}
}
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 ::
