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.
| Package | Affected versions | Patched versions |
|---|---|---|
tensorflowPyPI | >= 2.6.0, < 2.6.1 | 2.6.1 |
tensorflowPyPI | >= 2.5.0, < 2.5.2 | 2.5.2 |
tensorflowPyPI | < 2.4.4 | 2.4.4 |
tensorflow-cpuPyPI | >= 2.6.0, < 2.6.1 | 2.6.1 |
tensorflow-cpuPyPI | >= 2.5.0, < 2.5.2 | 2.5.2 |
tensorflow-cpuPyPI | < 2.4.4 | 2.4.4 |
tensorflow-gpuPyPI | >= 2.6.0, < 2.6.1 | 2.6.1 |
tensorflow-gpuPyPI | >= 2.5.0, < 2.5.2 | 2.5.2 |
tensorflow-gpuPyPI | < 2.4.4 | 2.4.4 |
Affected products
1- Range: >= 2.6.0, < 2.6.1
Patches
1874bda09e670Merge pull request #51715 from yongtang:46909-tf.summary.create_file_writer
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- github.com/advisories/GHSA-gh8h-7j2j-qv4fghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2021-41200ghsaADVISORY
- github.com/pypa/advisory-database/tree/main/vulns/tensorflow-cpu/PYSEC-2021-610.yamlghsaWEB
- github.com/pypa/advisory-database/tree/main/vulns/tensorflow-gpu/PYSEC-2021-808.yamlghsaWEB
- github.com/pypa/advisory-database/tree/main/vulns/tensorflow/PYSEC-2021-393.yamlghsaWEB
- github.com/tensorflow/tensorflow/commit/874bda09e6702cd50bac90b453b50bcc65b2769eghsax_refsource_MISCWEB
- github.com/tensorflow/tensorflow/issues/46909ghsax_refsource_MISCWEB
- github.com/tensorflow/tensorflow/security/advisories/GHSA-gh8h-7j2j-qv4fghsax_refsource_CONFIRMWEB
News mentions
0No linked articles in our index yet.