Moderate severityNVD Advisory· Published May 20, 2022· Updated Apr 22, 2025
Missing validation causes denial of service in TensorFlow via `StagePeek`
CVE-2022-29195
Description
TensorFlow is an open source platform for machine learning. Prior to versions 2.9.0, 2.8.1, 2.7.2, and 2.6.4, the implementation of tf.raw_ops.StagePeek does not fully validate the input arguments. This results in a CHECK-failure which can be used to trigger a denial of service attack. The code assumes index is a scalar but there is no validation for this before accessing its value. Versions 2.9.0, 2.8.1, 2.7.2, and 2.6.4 contain a patch for this issue.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
tensorflowPyPI | < 2.6.4 | 2.6.4 |
tensorflowPyPI | >= 2.7.0, < 2.7.2 | 2.7.2 |
tensorflowPyPI | >= 2.8.0, < 2.8.1 | 2.8.1 |
tensorflow-cpuPyPI | < 2.6.4 | 2.6.4 |
tensorflow-cpuPyPI | >= 2.7.0, < 2.7.2 | 2.7.2 |
tensorflow-cpuPyPI | >= 2.8.0, < 2.8.1 | 2.8.1 |
tensorflow-gpuPyPI | < 2.6.4 | 2.6.4 |
tensorflow-gpuPyPI | >= 2.7.0, < 2.7.2 | 2.7.2 |
tensorflow-gpuPyPI | >= 2.8.0, < 2.8.1 | 2.8.1 |
Affected products
1- Range: < 2.6.4
Patches
1cebe3c45d763Fix tf.raw_ops.StagePeek vulnerability with invalid `index`.
3 files changed · +14 −1
tensorflow/core/kernels/stage_op.cc+2 −0 modified@@ -258,6 +258,8 @@ class StagePeekOp : public OpKernel { core::ScopedUnref scope(buf); Buffer::Tuple tuple; + OP_REQUIRES(ctx, TensorShapeUtils::IsScalar(ctx->input(0).shape()), + errors::InvalidArgument("index must be scalar")); std::size_t index = ctx->input(0).scalar<int>()(); OP_REQUIRES_OK(ctx, buf->Peek(index, &tuple));
tensorflow/python/kernel_tests/data_structures/stage_op_test.py+11 −0 modified@@ -13,6 +13,7 @@ # limitations under the License. # ============================================================================== from tensorflow.python.framework import dtypes +from tensorflow.python.framework import errors from tensorflow.python.framework import ops from tensorflow.python.framework import test_util from tensorflow.python.ops import array_ops @@ -134,6 +135,16 @@ def testPeek(self): for i in range(10): self.assertTrue(sess.run(peek, feed_dict={p: i}) == [i]) + def testPeekBadIndex(self): + stager = data_flow_ops.StagingArea([ + dtypes.int32, + ], shapes=[[10]]) + stager.put([array_ops.zeros([10], dtype=dtypes.int32)]) + + with self.assertRaisesRegex((ValueError, errors.InvalidArgumentError), + 'must be scalar'): + self.evaluate(stager.peek([])) + @test_util.run_deprecated_v1 def testSizeAndClear(self): with ops.Graph().as_default() as G:
tensorflow/python/ops/data_flow_ops.py+1 −1 modified@@ -1737,7 +1737,7 @@ def _check_put_dtypes(self, vals, indices=None): # Sanity check number of values if not len(vals) <= len(self._dtypes): - raise ValueError(f"Unexpected number of inputs {len(vals)} vs" + raise ValueError(f"Unexpected number of inputs {len(vals)} vs " f"{len(self._dtypes)}") tensors = []
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- github.com/advisories/GHSA-h48f-q7rw-hvr7ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2022-29195ghsaADVISORY
- github.com/tensorflow/tensorflow/blob/f3b9bf4c3c0597563b289c0512e98d4ce81f886e/tensorflow/core/kernels/stage_op.ccghsax_refsource_MISCWEB
- github.com/tensorflow/tensorflow/commit/cebe3c45d76357d201c65bdbbf0dbe6e8a63bbdbghsax_refsource_MISCWEB
- github.com/tensorflow/tensorflow/releases/tag/v2.6.4ghsax_refsource_MISCWEB
- github.com/tensorflow/tensorflow/releases/tag/v2.7.2ghsax_refsource_MISCWEB
- github.com/tensorflow/tensorflow/releases/tag/v2.8.1ghsax_refsource_MISCWEB
- github.com/tensorflow/tensorflow/releases/tag/v2.9.0ghsax_refsource_MISCWEB
- github.com/tensorflow/tensorflow/security/advisories/GHSA-h48f-q7rw-hvr7ghsax_refsource_CONFIRMWEB
News mentions
0No linked articles in our index yet.