{"id":"CVE-2021-29521","published":"2021-05-14T19:35:49Z","modified":"2024-08-03T22:11:05Z","title":"Segfault in SparseCountSparseOutput","vendor":"tensorflow","product":"tensorflow","tier":"tail","description":{"text":"TensorFlow is an end-to-end open source platform for machine learning. Specifying a negative dense shape in `tf.raw_ops.SparseCountSparseOutput` results in a segmentation fault being thrown out from the standard library as `std::vector` invariants are broken. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/8f7b60ee8c0206a2c99802e3a4d1bb55d2bc0624/tensorflow/core/kernels/count_ops.cc#L199-L213) assumes the first element of the dense shape is always positive and uses it to initialize a `BatchedMap<T>` (i.e., `std::vector<absl::flat_hash_map<int64,T>>`(https://github.com/tensorflow/tensorflow/blob/8f7b60ee8c0206a2c99802e3a4d1bb55d2bc0624/tensorflow/core/kernels/count_ops.cc#L27)) data structure. If the `shape` tensor has more than one element, `num_batches` is the first value in `shape`. Ensuring that the `dense_shape` argument is a valid tensor shape (that is, all elements are non-negative) solves this issue. The fix will be included in TensorFlow 2.5.0. We will also cherrypick this commit on TensorFlow 2.4.2 and TensorFlow 2.3.3.","provenance":"source","from":"CVE.org"},"cvss":{"score":2.5,"severity":"LOW","version":"3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.00189,"percentile":0.08723,"provenance":"source"},"cwes":[{"id":"CWE-131","name":"Incorrect Calculation of Buffer Size"}],"references":[{"url":"https://github.com/tensorflow/tensorflow/security/advisories/GHSA-hr84-fqvp-48mm","tags":["x_refsource_CONFIRM"]},{"url":"https://github.com/tensorflow/tensorflow/commit/c57c0b9f3a4f8684f3489dd9a9ec627ad8b599f5","tags":["x_refsource_MISC"]}],"priority":{"score":3.5,"factors":[{"name":"EPSS percentile","points":1.74},{"name":"CVSS severity","points":1.75}]},"vendorSlug":"tensorflow","affectedVersions":[{"vendor":"tensorflow","product":"tensorflow","versions":["< 2.3.3",">= 2.4.0, < 2.4.2"]}],"affected":[{"ecosystem":"PyPI","package":"tensorflow","vulnerableRanges":[">=2.3.0, <2.3.3",">=2.4.0, <2.4.2"],"patched":["2.3.3","2.4.2"],"from":["GHSA-hr84-fqvp-48mm","PYSEC-2021-158"],"provenance":"source"},{"ecosystem":"PyPI","package":"tensorflow-cpu","vulnerableRanges":[">=2.3.0, <2.3.3",">=2.4.0, <2.4.2"],"patched":["2.3.3","2.4.2"],"from":["GHSA-hr84-fqvp-48mm","PYSEC-2021-449"],"provenance":"source"},{"ecosystem":"PyPI","package":"tensorflow-gpu","vulnerableRanges":[">=2.3.0, <2.3.3",">=2.4.0, <2.4.2"],"patched":["2.3.3","2.4.2"],"from":["GHSA-hr84-fqvp-48mm","PYSEC-2021-647"],"provenance":"source"}],"summary":{"text":"The TensorFlow tf.raw_ops.SparseCountSparseOutput operation in the count_ops kernel mishandles a negative first element in its dense shape argument, because it assumes that value is always positive when initializing its batched map data structure. An attacker who can supply a local input with a negative dense shape can trigger a segmentation fault, and the attack requires local access with low privileges and a specific user interaction condition.","provenance":"ai","model":"claude-haiku-5-5","generatedAt":"2026-11-20T22:23:07Z"},"euvd":{"id":"EUVD-2021-0262","exploited":false,"provenance":"source"}}