`CHECK` fail in `EmptyTensorList` in TensorFlow
Description
TensorFlow is an open source platform for machine learning. If EmptyTensorList receives an input element_shape with more than one dimension, it gives a CHECK fail that can be used to trigger a denial of service attack. We have patched the issue in GitHub commit c8ba76d48567aed347508e0552a257641931024d. The fix will be included in TensorFlow 2.10.0. We will also cherrypick this commit on TensorFlow 2.9.1, TensorFlow 2.8.1, and TensorFlow 2.7.2, as these are also affected and still in supported range. There are no known workarounds for this issue.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
tensorflowPyPI | < 2.7.2 | 2.7.2 |
tensorflowPyPI | >= 2.8.0, < 2.8.1 | 2.8.1 |
tensorflowPyPI | >= 2.9.0, < 2.9.1 | 2.9.1 |
Affected products
1- Range: < 2.7.2
Patches
1c8ba76d48567Fix tf.raw_ops.EmptyTensorList vulnerability with invalid `element_shape`.
2 files changed · +16 −4
tensorflow/core/kernels/list_kernels.cc+7 −4 modified@@ -21,7 +21,11 @@ limitations under the License. #include "tensorflow/core/kernels/list_kernels.h" +#include <algorithm> +#include <iterator> #include <limits> +#include <memory> +#include <utility> #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor" #include "tensorflow/core/framework/allocator.h" @@ -30,10 +34,6 @@ limitations under the License. #include "tensorflow/core/framework/tensor_types.h" #include "tensorflow/core/framework/variant.h" #include "tensorflow/core/framework/variant_op_registry.h" -#include "tensorflow/core/kernels/concat_lib.h" -#include "tensorflow/core/lib/core/coding.h" -#include "tensorflow/core/lib/core/errors.h" -#include "tensorflow/core/util/util.h" namespace tensorflow { @@ -49,6 +49,9 @@ Status TensorShapeFromTensor(const Tensor& t, PartialTensorShape* out) { return errors::InvalidArgument( "The only valid scalar shape tensor is the fully unknown shape " "specified as -1."); + } else if (t.shape().dims() != 1) { + return errors::InvalidArgument("Shape must be at most rank 1 but is rank ", + t.shape().dims()); } if (t.dtype() == DT_INT32) { return PartialTensorShape::MakePartialShape(t.vec<int32>().data(),
tensorflow/python/kernel_tests/data_structures/list_ops_test.py+9 −0 modified@@ -1458,6 +1458,15 @@ def testConcatWithUninitializedTensorsFailsIfNoInputLengths(self): t = list_ops.tensor_list_concat(l, element_dtype=dtypes.float32) self.evaluate(t) + def testEmptyTensorListInvalidShape(self): + with self.assertRaisesRegex((ValueError, errors.InvalidArgumentError), + r"Shape must be at most rank 1 but is rank 2"): + t = gen_list_ops.EmptyTensorList( + element_shape=array_ops.ones(dtype=dtypes.int32, shape=[1, 0]), + max_num_elements=constant_op.constant(1), + element_dtype=dtypes.int32) + self.evaluate(t) + def testEvenSplit(self): def RunTest(input_tensor, lengths, expected_stacked_output):
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- github.com/advisories/GHSA-qhw4-wwr7-gjc5ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2022-35998ghsaADVISORY
- github.com/tensorflow/tensorflow/commit/c8ba76d48567aed347508e0552a257641931024dghsax_refsource_MISCWEB
- github.com/tensorflow/tensorflow/releases/tag/v2.10.0ghsaWEB
- github.com/tensorflow/tensorflow/security/advisories/GHSA-qhw4-wwr7-gjc5ghsax_refsource_CONFIRMWEB
News mentions
0No linked articles in our index yet.