VYPR
Moderate severityNVD Advisory· Published Nov 18, 2022· Updated Apr 22, 2025

Segfault via invalid attributes in `pywrap_tfe_src.cc` in Tensorflow

CVE-2022-41889

Description

TensorFlow is an open source platform for machine learning. If a list of quantized tensors is assigned to an attribute, the pywrap code fails to parse the tensor and returns a nullptr, which is not caught. An example can be seen in tf.compat.v1.extract_volume_patches by passing in quantized tensors as input ksizes. We have patched the issue in GitHub commit e9e95553e5411834d215e6770c81a83a3d0866ce. The fix will be included in TensorFlow 2.11. We will also cherrypick this commit on TensorFlow 2.10.1, 2.9.3, and TensorFlow 2.8.4, as these are also affected and still in supported range.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
tensorflowPyPI
< 2.8.42.8.4
tensorflowPyPI
>= 2.9.0, < 2.9.32.9.3
tensorflowPyPI
>= 2.10.0, < 2.10.12.10.1
tensorflow-cpuPyPI
< 2.8.42.8.4
tensorflow-gpuPyPI
< 2.8.42.8.4
tensorflow-cpuPyPI
>= 2.9.0, < 2.9.32.9.3
tensorflow-gpuPyPI
>= 2.9.0, < 2.9.32.9.3
tensorflow-cpuPyPI
>= 2.10.0, < 2.10.12.10.1
tensorflow-gpuPyPI
>= 2.10.0, < 2.10.12.10.1

Affected products

1

Patches

1
e9e95553e541

Fix pywrap attribute read security vulnerability.

https://github.com/tensorflow/tensorflowAntonio SanchezSep 26, 2022via ghsa
2 files changed · +27 5
  • tensorflow/python/eager/pywrap_tfe_src.cc+14 5 modified
    @@ -397,11 +397,20 @@ bool SetOpAttrList(TFE_Context* ctx, TFE_Op* op, const char* key,
       const int num_values = PySequence_Size(py_list);
       if (attr_list_sizes != nullptr) (*attr_list_sizes)[key] = num_values;
     
    -#define PARSE_LIST(c_type, parse_fn)                                      \
    -  std::unique_ptr<c_type[]> values(new c_type[num_values]);               \
    -  for (int i = 0; i < num_values; ++i) {                                  \
    -    tensorflow::Safe_PyObjectPtr py_value(PySequence_ITEM(py_list, i));   \
    -    if (!parse_fn(key, py_value.get(), status, &values[i])) return false; \
    +#define PARSE_LIST(c_type, parse_fn)                                       \
    +  std::unique_ptr<c_type[]> values(new c_type[num_values]);                \
    +  for (int i = 0; i < num_values; ++i) {                                   \
    +    tensorflow::Safe_PyObjectPtr py_value(PySequence_ITEM(py_list, i));    \
    +    if (py_value == nullptr) {                                             \
    +      TF_SetStatus(status, TF_INVALID_ARGUMENT,                            \
    +                   tensorflow::strings::StrCat(                            \
    +                       "Expecting sequence of " #c_type " for attr ", key, \
    +                       ", got ", py_list->ob_type->tp_name)                \
    +                       .c_str());                                          \
    +      return false;                                                        \
    +    } else if (!parse_fn(key, py_value.get(), status, &values[i])) {       \
    +      return false;                                                        \
    +    }                                                                      \
       }
     
       if (type == TF_ATTR_STRING) {
    
  • tensorflow/python/kernel_tests/image_ops/extract_image_patches_op_test.py+13 0 modified
    @@ -17,7 +17,9 @@
     import numpy as np
     
     from tensorflow.python.framework import constant_op
    +from tensorflow.python.framework import dtypes
     from tensorflow.python.ops import array_ops
    +from tensorflow.python.ops import math_ops
     from tensorflow.python.platform import test
     
     
    @@ -139,6 +141,17 @@ def testComplexDataTypes(self):
                 padding=padding,
                 patches=patches)
     
    +  def testInvalidAttributes(self):
    +    """Test for passing weird things into ksizes."""
    +    with self.assertRaisesRegex(TypeError, "Expected list"):
    +      image = constant_op.constant([0.0])
    +      ksizes = math_ops.cast(
    +          constant_op.constant(dtype=dtypes.int16, value=[[1, 4], [5, 2]]),
    +          dtype=dtypes.qint16)
    +      strides = [1, 1, 1, 1]
    +      self.evaluate(
    +          array_ops.extract_image_patches(
    +              image, ksizes=ksizes, strides=strides, padding="SAME"))
     
     if __name__ == "__main__":
       test.main()
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

5

News mentions

0

No linked articles in our index yet.