{"id":"CVE-2021-29554","aliases":["BIT-tensorflow-2021-29554","EUVD-2021-0295","GHSA-qg48-85hg-mqc5","PYSEC-2021-191","PYSEC-2021-482","PYSEC-2021-680"],"status":"published","title":"Division by 0 in `DenseCountSparseOutput`","description":"TensorFlow is an end-to-end open source platform for machine learning. An attacker can cause a denial of service via a FPE runtime error in `tf.raw_ops.DenseCountSparseOutput`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/efff014f3b2d8ef6141da30c806faf141297eca1/tensorflow/core/kernels/count_ops.cc#L123-L127) computes a divisor value from user data but does not check that the result is 0 before doing the division. Since `data` is given by the `values` argument, `num_batch_elements` is 0. 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, as these are also affected.","severity":{"version":"3.1","score":2.5,"vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L","level":"low","assessor":"cna","from":"cve"},"epss":{"day":"2026-11-08","score":0.00189,"percentile":0.08583,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-369"],"published":"2021-05-14T19:10:15Z","modified":"2026-10-20T14:24:30Z","fixes":[{"ecosystem":"PyPI","package":"tensorflow","fixed_in":["2.3.3","2.4.2","2.1.4","2.2.3"],"sources":["ghsa","osv"]},{"ecosystem":"PyPI","package":"tensorflow-cpu","fixed_in":["2.3.3","2.4.2","2.1.4","2.2.3"],"sources":["ghsa","osv"]},{"ecosystem":"PyPI","package":"tensorflow-gpu","fixed_in":["2.3.3","2.4.2","2.1.4","2.2.3"],"sources":["ghsa","osv"]},{"ecosystem":"Bitnami","package":"tensorflow","fixed_in":["2.1.4","2.2.3","2.3.3","2.4.2"],"sources":["osv"]}],"affected":[{"source":"ghsa","ecosystem":"PyPI","package":"tensorflow","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.3.0"},{"fixed":"2.3.3"}]}]},{"source":"ghsa","ecosystem":"PyPI","package":"tensorflow","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.4.0"},{"fixed":"2.4.2"}]}]},{"source":"ghsa","ecosystem":"PyPI","package":"tensorflow-cpu","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.3.0"},{"fixed":"2.3.3"}]}]},{"source":"ghsa","ecosystem":"PyPI","package":"tensorflow-cpu","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.4.0"},{"fixed":"2.4.2"}]}]},{"source":"ghsa","ecosystem":"PyPI","package":"tensorflow-gpu","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.3.0"},{"fixed":"2.3.3"}]}]},{"source":"ghsa","ecosystem":"PyPI","package":"tensorflow-gpu","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.4.0"},{"fixed":"2.4.2"}]}]},{"source":"osv","ecosystem":"Bitnami","package":"tensorflow","ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"2.1.4"},{"introduced":"2.2.0"},{"fixed":"2.2.3"},{"introduced":"2.3.0"},{"fixed":"2.3.3"},{"introduced":"2.4.0"},{"fixed":"2.4.2"}]}]},{"source":"osv","ecosystem":"PyPI","package":"tensorflow","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.3.0"},{"fixed":"2.3.3"}]}],"versions":["2.3.0","2.3.1","2.3.2"]},{"source":"osv","ecosystem":"PyPI","package":"tensorflow","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.4.0"},{"fixed":"2.4.2"}]}],"versions":["2.4.0","2.4.1"]},{"source":"osv","ecosystem":"PyPI","package":"tensorflow-cpu","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.3.0"},{"fixed":"2.3.3"}]}],"versions":["2.3.0","2.3.1","2.3.2"]},{"source":"osv","ecosystem":"PyPI","package":"tensorflow-cpu","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.4.0"},{"fixed":"2.4.2"}]}],"versions":["2.4.0","2.4.1"]},{"source":"osv","ecosystem":"PyPI","package":"tensorflow-gpu","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.3.0"},{"fixed":"2.3.3"}]}],"versions":["2.3.0","2.3.1","2.3.2"]},{"source":"osv","ecosystem":"PyPI","package":"tensorflow-gpu","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2.4.0"},{"fixed":"2.4.2"}]}],"versions":["2.4.0","2.4.1"]},{"source":"osv","ecosystem":"PyPI","package":"tensorflow","ranges":[{"type":"GIT","events":[{"introduced":"0"},{"fixed":"da5ff2daf618591f64b2b62d9d9803951b945e9f"}]},{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"2.1.4"},{"introduced":"2.2.0"},{"fixed":"2.2.3"},{"introduced":"2.3.0"},{"fixed":"2.3.3"},{"introduced":"2.4.0"},{"fixed":"2.4.2"}]}],"versions":["0.12.0","0.12.0rc0","0.12.0rc1","0.12.1","1.0.0","1.0.1","1.1.0","1.1.0rc0","1.1.0rc1","1.1.0rc2","1.10.0","1.10.0rc0","1.10.0rc1","1.10.1","1.11.0","1.11.0rc0","1.11.0rc1","1.11.0rc2","1.12.0","1.12.0rc0","1.12.0rc1","1.12.0rc2","1.12.2","1.12.3","1.13.0rc0","1.13.0rc1","1.13.0rc2","1.13.1","1.13.2","1.14.0","1.14.0rc0","1.14.0rc1","1.15.0","1.15.0rc0","1.15.0rc1","1.15.0rc2","1.15.0rc3","1.15.2","1.15.3","1.15.4","1.15.5","1.2.0","1.2.0rc0","1.2.0rc1","1.2.0rc2","1.2.1","1.3.0","1.3.0rc0","1.3.0rc1","1.3.0rc2","1.4.0","1.4.0rc0","1.4.0rc1","1.4.1","1.5.0","1.5.0rc0","1.5.0rc1","1.5.1","1.6.0","1.6.0rc0","1.6.0rc1","1.7.0","1.7.0rc0","1.7.0rc1","1.7.1","1.8.0","1.8.0rc0","1.8.0rc1","1.9.0","1.9.0rc0","1.9.0rc1","1.9.0rc2","2.0.0","2.0.0a0","2.0.0b0","2.0.0b1","2.0.0rc0","2.0.0rc1","2.0.0rc2","2.0.1","2.0.2","2.0.3","2.0.4","2.1.0","2.1.0rc0","2.1.0rc1","2.1.0rc2","2.1.1","2.1.2","2.1.3","2.2.0","2.2.1","2.2.2","2.3.0","2.3.1","2.3.2","2.4.0","2.4.1"]},{"source":"osv","ecosystem":"PyPI","package":"tensorflow-cpu","ranges":[{"type":"GIT","events":[{"introduced":"0"},{"fixed":"da5ff2daf618591f64b2b62d9d9803951b945e9f"}]},{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"2.1.4"},{"introduced":"2.2.0"},{"fixed":"2.2.3"},{"introduced":"2.3.0"},{"fixed":"2.3.3"},{"introduced":"2.4.0"},{"fixed":"2.4.2"}]}],"versions":["1.15.0","2.1.0","2.1.1","2.1.2","2.1.3","2.2.0","2.2.1","2.2.2","2.3.0","2.3.1","2.3.2","2.4.0","2.4.1"]},{"source":"osv","ecosystem":"PyPI","package":"tensorflow-gpu","ranges":[{"type":"GIT","events":[{"introduced":"0"},{"fixed":"da5ff2daf618591f64b2b62d9d9803951b945e9f"}]},{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"2.1.4"},{"introduced":"2.2.0"},{"fixed":"2.2.3"},{"introduced":"2.3.0"},{"fixed":"2.3.3"},{"introduced":"2.4.0"},{"fixed":"2.4.2"}]}],"versions":["0.12.0","0.12.1","1.0.0","1.0.1","1.1.0","1.10.0","1.10.1","1.11.0","1.12.0","1.12.2","1.12.3","1.13.1","1.13.2","1.14.0","1.15.0","1.15.2","1.15.3","1.15.4","1.15.5","1.2.0","1.2.1","1.3.0","1.4.0","1.4.1","1.5.0","1.5.1","1.6.0","1.7.0","1.7.1","1.8.0","1.9.0","2.0.0","2.0.1","2.0.2","2.0.3","2.0.4","2.1.0","2.1.1","2.1.2","2.1.3","2.2.0","2.2.1","2.2.2","2.3.0","2.3.1","2.3.2","2.4.0","2.4.1"]}],"products":[{"vendor":"google","product":"tensorflow"},{"vendor":"tensorflow","product":"tensorflow"}],"references":[{"url":"https://github.com/tensorflow/tensorflow/security/advisories/GHSA-qg48-85hg-mqc5","tags":["x_refsource_CONFIRM","x_transferred","Exploit","Patch","Third Party Advisory","advisory","fix","web"]},{"url":"https://github.com/tensorflow/tensorflow/commit/da5ff2daf618591f64b2b62d9d9803951b945e9f","tags":["x_refsource_MISC","x_transferred","Patch","Third Party Advisory","advisory","fix","web"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-29554","tags":["web","advisory"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-cpu/PYSEC-2021-482.yaml","tags":["web"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-gpu/PYSEC-2021-680.yaml","tags":["web"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow/PYSEC-2021-191.yaml","tags":["web"]},{"url":"https://github.com/advisories/GHSA-qg48-85hg-mqc5"},{"url":"https://github.com/tensorflow/tensorflow","tags":["package"]}],"sources":{"cve":[{"id":"CVE-2021-29554","title":"Division by 0 in `DenseCountSparseOutput`","description":"TensorFlow is an end-to-end open source platform for machine learning. An attacker can cause a denial of service via a FPE runtime error in `tf.raw_ops.DenseCountSparseOutput`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/efff014f3b2d8ef6141da30c806faf141297eca1/tensorflow/core/kernels/count_ops.cc#L123-L127) computes a divisor value from user data but does not check that the result is 0 before doing the division. Since `data` is given by the `values` argument, `num_batch_elements` is 0. 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, as these are also affected.","status":"published","published":"2021-05-14T19:10:15Z","modified":"2024-08-03T22:11:06.254Z","cvss":[{"version":"3.1","score":2.5,"vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L","level":"low","assessor":"cna"}],"cwes":["CWE-369"],"updated_at":"2026-11-02T14:33:06.32268Z"}],"euvd":[{"id":"EUVD-2021-0295","description":"TensorFlow is an end-to-end open source platform for machine learning. An attacker can cause a denial of service via a FPE runtime error in `tf.raw_ops.DenseCountSparseOutput`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/efff014f3b2d8ef6141da30c806faf141297eca1/tensorflow/core/kernels/count_ops.cc#L123-L127) computes a divisor value from user data but does not check that the result is 0 before doing the division. Since `data` is given by the `values` argument, `num_batch_elements` is 0. 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, as these are also affected.","status":"published","published":"2021-05-14T19:10:15Z","modified":"2024-08-03T22:11:06Z","cvss":[{"version":"3.1","score":2.5,"vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L","level":"low"}],"updated_at":"2026-11-03T03:24:43.965438Z"}],"ghsa":[{"id":"GHSA-qg48-85hg-mqc5","title":"Division by 0 in `DenseCountSparseOutput`","description":"### Impact\nAn attacker can cause a denial of service via a FPE runtime error in `tf.raw_ops.DenseCountSparseOutput`:\n\n```python\nimport tensorflow as tf\n\nvalues = tf.constant([], shape=[0, 0], dtype=tf.int64)\nweights = tf.constant([])\n\ntf.raw_ops.DenseCountSparseOutput(\n  values=values, weights=weights,\n  minlength=-1, maxlength=58, binary_output=True)\n```\n  \nThis is because the [implementation](https://github.com/tensorflow/tensorflow/blob/efff014f3b2d8ef6141da30c806faf141297eca1/tensorflow/core/kernels/count_ops.cc#L123-L127) computes a divisor value from user data but does not check that the result is 0 before doing the division:\n\n```cc\nint num_batch_elements = 1;\nfor (int i = 0; i \u003c num_batch_dimensions; ++i) {\n  num_batch_elements *= data.shape().dim_size(i);\n}\nint num_value_elements = data.shape().num_elements() / num_batch_elements;\n```\n\nSince `data` is given by the `values` argument, `num_batch_elements` is 0.\n\n### Patches\nWe have patched the issue in GitHub commit [da5ff2daf618591f64b2b62d9d9803951b945e9f](https://github.com/tensorflow/tensorflow/commit/da5ff2daf618591f64b2b62d9d9803951b945e9f).\n\nThe 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, as these are also affected.\n\n### For more information\nPlease consult [our security guide](https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md) for more information regarding the security model and how to contact us with issues and questions.\n\n### Attribution\nThis vulnerability has been reported by Yakun Zhang and Ying Wang of Baidu X-Team.","status":"published","published":"2021-05-21T14:23:55Z","modified":"2024-10-31T20:52:11Z","cvss":[{"version":"4.0","score":2,"vector":"CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N","level":"low"},{"version":"3.1","score":2.5,"vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L","level":"low"}],"cwes":["CWE-369"],"updated_at":"2026-11-02T14:38:15.606692Z"}],"nvd":[{"id":"CVE-2021-29554","description":"TensorFlow is an end-to-end open source platform for machine learning. An attacker can cause a denial of service via a FPE runtime error in `tf.raw_ops.DenseCountSparseOutput`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/efff014f3b2d8ef6141da30c806faf141297eca1/tensorflow/core/kernels/count_ops.cc#L123-L127) computes a divisor value from user data but does not check that the result is 0 before doing the division. Since `data` is given by the `values` argument, `num_batch_elements` is 0. 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, as these are also affected.","status":"published","published":"2021-05-14T19:15:07.8Z","modified":"2026-06-17T03:47:54Z","cvss":[{"version":"3.1","score":2.5,"vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L","level":"low","assessor":"secondary"},{"version":"3.1","score":5.5,"vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","level":"medium","assessor":"primary"},{"version":"2.0","score":2.1,"vector":"AV:L/AC:L/Au:N/C:N/I:N/A:P","level":"low","assessor":"primary"}],"cwes":["CWE-369"],"updated_at":"2026-11-02T14:06:53.343329Z"}],"osv":[{"id":"CVE-2021-29554","description":"TensorFlow is an end-to-end open source platform for machine learning. An attacker can cause a denial of service via a FPE runtime error in `tf.raw_ops.DenseCountSparseOutput`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/efff014f3b2d8ef6141da30c806faf141297eca1/tensorflow/core/kernels/count_ops.cc#L123-L127) computes a divisor value from user data but does not check that the result is 0 before doing the division. Since `data` is given by the `values` argument, `num_batch_elements` is 0. 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, as these are also affected.","status":"published","published":"2021-05-14T19:15:07.8Z","modified":"2026-10-20T14:24:30.106944359Z","cvss":[{"version":"3.1","score":5.5,"vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","level":"medium"}],"updated_at":"2026-11-02T15:44:19.129331Z"},{"id":"GHSA-qg48-85hg-mqc5","title":"Division by 0 in `DenseCountSparseOutput`","description":"### Impact\nAn attacker can cause a denial of service via a FPE runtime error in `tf.raw_ops.DenseCountSparseOutput`:\n\n```python\nimport tensorflow as tf\n\nvalues = tf.constant([], shape=[0, 0], dtype=tf.int64)\nweights = tf.constant([])\n\ntf.raw_ops.DenseCountSparseOutput(\n  values=values, weights=weights,\n  minlength=-1, maxlength=58, binary_output=True)\n```\n  \nThis is because the [implementation](https://github.com/tensorflow/tensorflow/blob/efff014f3b2d8ef6141da30c806faf141297eca1/tensorflow/core/kernels/count_ops.cc#L123-L127) computes a divisor value from user data but does not check that the result is 0 before doing the division:\n\n```cc\nint num_batch_elements = 1;\nfor (int i = 0; i \u003c num_batch_dimensions; ++i) {\n  num_batch_elements *= data.shape().dim_size(i);\n}\nint num_value_elements = data.shape().num_elements() / num_batch_elements;\n```\n\nSince `data` is given by the `values` argument, `num_batch_elements` is 0.\n\n### Patches\nWe have patched the issue in GitHub commit [da5ff2daf618591f64b2b62d9d9803951b945e9f](https://github.com/tensorflow/tensorflow/commit/da5ff2daf618591f64b2b62d9d9803951b945e9f).\n\nThe 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, as these are also affected.\n\n### For more information\nPlease consult [our security guide](https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md) for more information regarding the security model and how to contact us with issues and questions.\n\n### Attribution\nThis vulnerability has been reported by Yakun Zhang and Ying Wang of Baidu X-Team.","status":"published","published":"2021-05-21T14:23:55Z","modified":"2026-07-08T06:29:58.748339946Z","cvss":[{"version":"3.1","score":2.5,"vector":"CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:L","level":"low"},{"version":"4.0","score":2,"vector":"CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N","level":"low"}],"cwes":["CWE-369"],"updated_at":"2026-11-02T15:46:54.40888Z"},{"id":"BIT-tensorflow-2021-29554","title":"Division by 0 in `DenseCountSparseOutput`","description":"TensorFlow is an end-to-end open source platform for machine learning. An attacker can cause a denial of service via a FPE runtime error in `tf.raw_ops.DenseCountSparseOutput`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/efff014f3b2d8ef6141da30c806faf141297eca1/tensorflow/core/kernels/count_ops.cc#L123-L127) computes a divisor value from user data but does not check that the result is 0 before doing the division. Since `data` is given by the `values` argument, `num_batch_elements` is 0. 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, as these are also affected.","status":"published","published":"2024-03-06T11:19:17.329Z","modified":"2026-09-08T08:48:19.947961911Z","updated_at":"2026-11-02T15:28:35.51001Z"},{"id":"PYSEC-2021-191","description":"TensorFlow is an end-to-end open source platform for machine learning. An attacker can cause a denial of service via a FPE runtime error in `tf.raw_ops.DenseCountSparseOutput`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/efff014f3b2d8ef6141da30c806faf141297eca1/tensorflow/core/kernels/count_ops.cc#L123-L127) computes a divisor value from user data but does not check that the result is 0 before doing the division. Since `data` is given by the `values` argument, `num_batch_elements` is 0. 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, as these are also affected.","status":"published","published":"2021-05-14T19:15:00Z","modified":"2023-12-06T01:01:05.748644Z","updated_at":"2026-11-02T15:52:52.682031Z"},{"id":"PYSEC-2021-482","description":"TensorFlow is an end-to-end open source platform for machine learning. An attacker can cause a denial of service via a FPE runtime error in `tf.raw_ops.DenseCountSparseOutput`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/efff014f3b2d8ef6141da30c806faf141297eca1/tensorflow/core/kernels/count_ops.cc#L123-L127) computes a divisor value from user data but does not check that the result is 0 before doing the division. Since `data` is given by the `values` argument, `num_batch_elements` is 0. 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, as these are also affected.","status":"published","published":"2021-05-14T19:15:00Z","modified":"2023-12-06T01:01:05.748644Z","updated_at":"2026-11-02T15:52:53.119977Z"},{"id":"PYSEC-2021-680","description":"TensorFlow is an end-to-end open source platform for machine learning. An attacker can cause a denial of service via a FPE runtime error in `tf.raw_ops.DenseCountSparseOutput`. This is because the implementation(https://github.com/tensorflow/tensorflow/blob/efff014f3b2d8ef6141da30c806faf141297eca1/tensorflow/core/kernels/count_ops.cc#L123-L127) computes a divisor value from user data but does not check that the result is 0 before doing the division. Since `data` is given by the `values` argument, `num_batch_elements` is 0. 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, as these are also affected.","status":"published","published":"2021-05-14T19:15:00Z","modified":"2023-12-06T01:01:05.748644Z","updated_at":"2026-11-02T15:52:53.119977Z"}]}}
