VYPR
Moderate severityNVD Advisory· Published Sep 25, 2020· Updated Aug 4, 2024

Data leak in Tensorflow

CVE-2020-15205

Description

In Tensorflow before versions 1.15.4, 2.0.3, 2.1.2, 2.2.1 and 2.3.1, the data_splits argument of tf.raw_ops.StringNGrams lacks validation. This allows a user to pass values that can cause heap overflow errors and even leak contents of memory In the linked code snippet, all the binary strings after ee ff are contents from the memory stack. Since these can contain return addresses, this data leak can be used to defeat ASLR. The issue is patched in commit 0462de5b544ed4731aa2fb23946ac22c01856b80, and is released in TensorFlow versions 1.15.4, 2.0.3, 2.1.2, 2.2.1, or 2.3.1.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
tensorflowPyPI
< 1.15.41.15.4
tensorflowPyPI
>= 2.0.0, < 2.0.32.0.3
tensorflowPyPI
>= 2.1.0, < 2.1.22.1.2
tensorflowPyPI
>= 2.2.0, < 2.2.12.2.1
tensorflowPyPI
>= 2.3.0, < 2.3.12.3.1
tensorflow-cpuPyPI
< 1.15.41.15.4
tensorflow-cpuPyPI
>= 2.0.0, < 2.0.32.0.3
tensorflow-cpuPyPI
>= 2.1.0, < 2.1.22.1.2
tensorflow-cpuPyPI
>= 2.2.0, < 2.2.12.2.1
tensorflow-cpuPyPI
>= 2.3.0, < 2.3.12.3.1
tensorflow-gpuPyPI
< 1.15.41.15.4
tensorflow-gpuPyPI
>= 2.0.0, < 2.0.32.0.3
tensorflow-gpuPyPI
>= 2.1.0, < 2.1.22.1.2
tensorflow-gpuPyPI
>= 2.2.0, < 2.2.12.2.1
tensorflow-gpuPyPI
>= 2.3.0, < 2.3.12.3.1

Affected products

1

Patches

1
0462de5b544e

Validate `data_splits` for `tf.StringNGrams`.

https://github.com/tensorflow/tensorflowMihai MaruseacSep 18, 2020via ghsa
2 files changed · +35 1
  • tensorflow/core/kernels/string_ngrams_op.cc+13 0 modified
    @@ -19,6 +19,7 @@ limitations under the License.
     #include "absl/strings/ascii.h"
     #include "absl/strings/str_cat.h"
     #include "tensorflow/core/framework/op_kernel.h"
    +#include "tensorflow/core/platform/errors.h"
     
     namespace tensorflow {
     namespace text {
    @@ -60,6 +61,18 @@ class StringNGramsOp : public tensorflow::OpKernel {
         OP_REQUIRES_OK(context, context->input("data_splits", &splits));
         const auto& splits_vec = splits->flat<SPLITS_TYPE>();
     
    +    // Validate that the splits are valid indices into data
    +    const int input_data_size = data->flat<tstring>().size();
    +    const int splits_vec_size = splits_vec.size();
    +    for (int i = 0; i < splits_vec_size; ++i) {
    +      bool valid_splits = splits_vec(i) >= 0;
    +      valid_splits = valid_splits && (splits_vec(i) <= input_data_size);
    +      OP_REQUIRES(
    +          context, valid_splits,
    +          errors::InvalidArgument("Invalid split value ", splits_vec(i),
    +                                  ", must be in [0,", input_data_size, "]"));
    +    }
    +
         int num_batch_items = splits_vec.size() - 1;
         tensorflow::Tensor* ngrams_splits;
         OP_REQUIRES_OK(
    
  • tensorflow/python/ops/raw_ops_test.py+22 1 modified
    @@ -18,16 +18,21 @@
     from __future__ import division
     from __future__ import print_function
     
    +from absl.testing import parameterized
    +
     from tensorflow.python.eager import context
     from tensorflow.python.framework import constant_op
    +from tensorflow.python.framework import errors
     from tensorflow.python.framework import ops
     from tensorflow.python.framework import test_util
     from tensorflow.python.ops import gen_math_ops
    +from tensorflow.python.ops import gen_string_ops
     from tensorflow.python.platform import test
     
     
     @test_util.run_all_in_graph_and_eager_modes
    -class RawOpsTest(test.TestCase):
    +@test_util.disable_tfrt
    +class RawOpsTest(test.TestCase, parameterized.TestCase):
     
       def testSimple(self):
         x = constant_op.constant(1)
    @@ -58,6 +63,22 @@ def testDefaults(self):
             gen_math_ops.Any(input=x, axis=0),
             gen_math_ops.Any(input=x, axis=0, keep_dims=False))
     
    +  @parameterized.parameters([[0, 8]], [[-1, 6]])
    +  def testStringNGramsBadDataSplits(self, splits):
    +    data = ["aa", "bb", "cc", "dd", "ee", "ff"]
    +    with self.assertRaisesRegex(errors.InvalidArgumentError,
    +                                "Invalid split value"):
    +      self.evaluate(
    +          gen_string_ops.string_n_grams(
    +              data=data,
    +              data_splits=splits,
    +              separator="",
    +              ngram_widths=[2],
    +              left_pad="",
    +              right_pad="",
    +              pad_width=0,
    +              preserve_short_sequences=False))
    +
     
     if __name__ == "__main__":
       ops.enable_eager_execution()
    

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

9

News mentions

0

No linked articles in our index yet.