Integer overflow leading to crash in Tensorflow
Description
TensorFlow's SparseCountSparseOutput contains an integer overflow leading to denial of service.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
TensorFlow's `SparseCountSparseOutput` contains an integer overflow leading to denial of service.
Vulnerability
The SparseCountSparseOutput op in TensorFlow is vulnerable to an integer overflow during memory allocation. Versions 2.5.0 through 2.5.2, 2.6.0 through 2.6.2, and 2.7.0 are affected [1]. The overflow occurs when large input shapes trigger a multiplication that exceeds the maximum integer value, resulting in an undersized buffer allocation.
Exploitation
An attacker can trigger this vulnerability by providing a crafted SparseCountSparseOutput operation with large dimensions that cause an integer overflow. No authentication is required if the attacker can control the input to a TensorFlow model or session [1].
Impact
A successful exploitation causes a heap buffer overflow, leading to a crash (denial of service) of the TensorFlow process. There is no indication of remote code execution or information disclosure from the available references [1].
Mitigation
The fix is included in TensorFlow 2.8.0, and has been cherry-picked to versions 2.7.1, 2.6.3, and 2.5.3 [1]. Users should upgrade to one of these patched releases. No workaround is available for unpatched versions.
AI Insight generated on May 21, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
tensorflowPyPI | < 2.5.3 | 2.5.3 |
tensorflowPyPI | >= 2.6.0, < 2.6.3 | 2.6.3 |
tensorflowPyPI | >= 2.7.0, < 2.7.1 | 2.7.1 |
tensorflow-cpuPyPI | < 2.5.3 | 2.5.3 |
tensorflow-cpuPyPI | >= 2.6.0, < 2.6.3 | 2.6.3 |
tensorflow-cpuPyPI | >= 2.7.0, < 2.7.1 | 2.7.1 |
tensorflow-gpuPyPI | < 2.5.3 | 2.5.3 |
tensorflow-gpuPyPI | >= 2.6.0, < 2.6.3 | 2.6.3 |
tensorflow-gpuPyPI | >= 2.7.0, < 2.7.1 | 2.7.1 |
Affected products
5- osv-coords4 versions
< 2.5.3+ 3 more
- (no CPE)range: < 2.5.3
- (no CPE)range: < 2.5.3
- (no CPE)range: < 2.5.3
- (no CPE)range: < 2.5.3
Patches
16f4d3e8139ecPrevent crash due to integer overflow followed by allocating negative sized array.
1 file changed · +9 −0
tensorflow/core/kernels/count_ops.cc+9 −0 modified@@ -13,6 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ +#include <limits> + #include "absl/container/flat_hash_map.h" #include "tensorflow/core/framework/op_kernel.h" #include "tensorflow/core/framework/op_requires.h" @@ -23,6 +25,9 @@ limitations under the License. namespace tensorflow { +// Don't allocate too large `BatchedMap<T>` objects +static int kMaxBatches = std::numeric_limits<int>::max(); + template <class T> using BatchedMap = std::vector<absl::flat_hash_map<int64_t, T>>; @@ -235,6 +240,10 @@ class SparseCount : public OpKernel { bool is_1d = shape.NumElements() == 1; int num_batches = is_1d ? 1 : shape_vector(0); + OP_REQUIRES( + context, 0 < num_batches && num_batches < kMaxBatches, + errors::InvalidArgument("Cannot allocate ", num_batches, + " batches, is the dense shape too wide?")); const auto values_values = values.flat<T>(); const auto weight_values = weights.flat<W>();
Vulnerability mechanics
Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
7- github.com/advisories/GHSA-x4qx-4fjv-hmw6ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2022-21738ghsaADVISORY
- github.com/pypa/advisory-database/tree/main/vulns/tensorflow-cpu/PYSEC-2022-62.yamlghsaWEB
- github.com/pypa/advisory-database/tree/main/vulns/tensorflow-gpu/PYSEC-2022-117.yamlghsaWEB
- github.com/tensorflow/tensorflow/blob/5100e359aef5c8021f2e71c7b986420b85ce7b3d/tensorflow/core/kernels/count_ops.ccghsax_refsource_MISCWEB
- github.com/tensorflow/tensorflow/commit/6f4d3e8139ec724dbbcb40505891c81dd1052c4aghsax_refsource_MISCWEB
- github.com/tensorflow/tensorflow/security/advisories/GHSA-x4qx-4fjv-hmw6ghsax_refsource_CONFIRMWEB
News mentions
0No linked articles in our index yet.