VYPR
High severityNVD Advisory· Published Aug 12, 2021· Updated Aug 4, 2024

Segfault and heap buffer overflow in `{Experimental,}DatasetToTFRecord` in TensorFlow

CVE-2021-37650

Description

TensorFlow is an end-to-end open source platform for machine learning. In affected versions the implementation for tf.raw_ops.ExperimentalDatasetToTFRecord and tf.raw_ops.DatasetToTFRecord can trigger heap buffer overflow and segmentation fault. The implementation assumes that all records in the dataset are of string type. However, there is no check for that, and the example given above uses numeric types. We have patched the issue in GitHub commit e0b6e58c328059829c3eb968136f17aa72b6c876. The fix will be included in TensorFlow 2.6.0. We will also cherrypick this commit on TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.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.3.42.3.4
tensorflowPyPI
>= 2.4.0, < 2.4.32.4.3
tensorflowPyPI
>= 2.5.0, < 2.5.12.5.1
tensorflow-cpuPyPI
< 2.3.42.3.4
tensorflow-cpuPyPI
>= 2.4.0, < 2.4.32.4.3
tensorflow-cpuPyPI
>= 2.5.0, < 2.5.12.5.1
tensorflow-gpuPyPI
< 2.3.42.3.4
tensorflow-gpuPyPI
>= 2.4.0, < 2.4.32.4.3
tensorflow-gpuPyPI
>= 2.5.0, < 2.5.12.5.1

Affected products

1

Patches

1
e0b6e58c3280

Fix segfault/heap buffer overflow in `{Experimental,}DatasetToTFRecord` where dataset is numeric.

https://github.com/tensorflow/tensorflowMihai MaruseacJul 29, 2021via ghsa
1 file changed · +14 1
  • tensorflow/core/kernels/data/experimental/to_tf_record_op.cc+14 1 modified
    @@ -18,6 +18,7 @@ limitations under the License.
     #include "tensorflow/core/framework/function_handle_cache.h"
     #include "tensorflow/core/framework/op_kernel.h"
     #include "tensorflow/core/framework/resource_mgr.h"
    +#include "tensorflow/core/framework/types.h"
     #include "tensorflow/core/kernels/ops_util.h"
     #include "tensorflow/core/lib/core/threadpool.h"
     #include "tensorflow/core/lib/io/record_writer.h"
    @@ -91,8 +92,20 @@ class ToTFRecordOp : public AsyncOpKernel {
         TF_RETURN_IF_ERROR(finalized_dataset->MakeIterator(
             &iter_ctx, /*parent=*/nullptr, "ToTFRecordOpIterator", &iterator));
     
    +    const int num_output_dtypes = finalized_dataset->output_dtypes().size();
    +    if (num_output_dtypes != 1) {
    +      return errors::InvalidArgument(
    +          "ToTFRecordOp currently only support datasets of 1 single column, ",
    +          "but got ", num_output_dtypes);
    +    }
    +    const DataType dt = finalized_dataset->output_dtypes()[0];
    +    if (dt != DT_STRING) {
    +      return errors::InvalidArgument(
    +          "ToTFRecordOp currently only supports DT_STRING dataypes, but got ",
    +          DataTypeString(dt));
    +    }
         std::vector<Tensor> components;
    -    components.reserve(finalized_dataset->output_dtypes().size());
    +    components.reserve(num_output_dtypes);
         bool end_of_sequence;
         do {
           TF_RETURN_IF_ERROR(
    

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

7

News mentions

0

No linked articles in our index yet.