VYPR
Moderate severityNVD Advisory· Published Nov 5, 2021· Updated Nov 13, 2024

Incomplete validation in `tf.summary.create_file_writer`

CVE-2021-41200

Description

TensorFlow is an open source platform for machine learning. In affected versions if tf.summary.create_file_writer is called with non-scalar arguments code crashes due to a CHECK-fail. The fix will be included in TensorFlow 2.7.0. We will also cherrypick this commit on TensorFlow 2.6.1, TensorFlow 2.5.2, and TensorFlow 2.4.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.6.0, < 2.6.12.6.1
tensorflowPyPI
>= 2.5.0, < 2.5.22.5.2
tensorflowPyPI
< 2.4.42.4.4
tensorflow-cpuPyPI
>= 2.6.0, < 2.6.12.6.1
tensorflow-cpuPyPI
>= 2.5.0, < 2.5.22.5.2
tensorflow-cpuPyPI
< 2.4.42.4.4
tensorflow-gpuPyPI
>= 2.6.0, < 2.6.12.6.1
tensorflow-gpuPyPI
>= 2.5.0, < 2.5.22.5.2
tensorflow-gpuPyPI
< 2.4.42.4.4

Affected products

1

Patches

1
874bda09e670

Merge pull request #51715 from yongtang:46909-tf.summary.create_file_writer

https://github.com/tensorflow/tensorflowTensorFlower GardenerAug 31, 2021via ghsa
2 files changed · +19 0
  • tensorflow/core/kernels/summary_kernels.cc+8 0 modified
    @@ -38,12 +38,20 @@ class CreateSummaryFileWriterOp : public OpKernel {
       void Compute(OpKernelContext* ctx) override {
         const Tensor* tmp;
         OP_REQUIRES_OK(ctx, ctx->input("logdir", &tmp));
    +    OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(tmp->shape()),
    +                errors::InvalidArgument("logdir must be a scalar"));
         const string logdir = tmp->scalar<tstring>()();
         OP_REQUIRES_OK(ctx, ctx->input("max_queue", &tmp));
    +    OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(tmp->shape()),
    +                errors::InvalidArgument("max_queue must be a scalar"));
         const int32_t max_queue = tmp->scalar<int32>()();
         OP_REQUIRES_OK(ctx, ctx->input("flush_millis", &tmp));
    +    OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(tmp->shape()),
    +                errors::InvalidArgument("flush_millis must be a scalar"));
         const int32_t flush_millis = tmp->scalar<int32>()();
         OP_REQUIRES_OK(ctx, ctx->input("filename_suffix", &tmp));
    +    OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(tmp->shape()),
    +                errors::InvalidArgument("filename_suffix must be a scalar"));
         const string filename_suffix = tmp->scalar<tstring>()();
     
         core::RefCountPtr<SummaryWriterInterface> s;
    
  • tensorflow/python/summary/writer/writer_test.py+11 0 modified
    @@ -34,6 +34,7 @@
     from tensorflow.python.client import session
     from tensorflow.python.framework import constant_op
     from tensorflow.python.framework import dtypes
    +from tensorflow.python.framework import errors_impl
     from tensorflow.python.framework import meta_graph
     from tensorflow.python.framework import ops
     from tensorflow.python.framework import test_util
    @@ -685,6 +686,16 @@ def testSharing_withExplicitSummaryFileWriters(self):
         # No more files
         self.assertRaises(StopIteration, lambda: next(event_paths))
     
    +  def testSummaryFileWritersInvalidInput(self):
    +    # Test case for GitHub issue 46909
    +    logdir = self.get_temp_dir()
    +    with session.Session() as sess:
    +      with self.assertRaises(errors_impl.InvalidArgumentError):
    +        writer = summary_ops_v2.create_file_writer(
    +            logdir=logdir, flush_millis=[1, 2])
    +        sess.run(writer.init())
    +        sess.run(writer.flush())
    +
     
     class FileWriterCacheTest(test.TestCase):
       """FileWriterCache tests."""
    

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

8

News mentions

0

No linked articles in our index yet.