{"schemaVersion":3,"id":"CVE-2021-37640","aliases":["GHSA-95xm-g58g-3p88","BIT-tensorflow-2021-37640","PYSEC-2021-262","PYSEC-2021-553","PYSEC-2021-751"],"status":"published","duplicateOf":null,"title":null,"description":"TensorFlow is an end-to-end open source platform for machine learning. In affected versions the implementation of `tf.raw_ops.SparseReshape` can be made to trigger an integral division by 0 exception. The [implementation](https://github.com/tensorflow/tensorflow/blob/8d72537c6abf5a44103b57b9c2e22c14f5f49698/tensorflow/core/kernels/reshape_util.cc#L176-L181) calls the reshaping functor whenever there is at least an index in the input but does not check that shape of the input or the target shape have both a non-zero number of elements. The [reshape functor](https://github.com/tensorflow/tensorflow/blob/8d72537c6abf5a44103b57b9c2e22c14f5f49698/tensorflow/core/kernels/reshape_util.cc#L40-L78) blindly divides by the dimensions of the target shape. Hence, if this is not checked, code will result in a division by 0. We have patched the issue in GitHub commit 4923de56ec94fff7770df259ab7f2288a74feb41. The fix will be included in TensorFlow 2.6.0. We will also cherrypick this commit on TensorFlow 2.5.1 as this is the other affected version.","dates":{"published":"2021-08-12T17:35:11.000Z","modified":"2024-08-04T01:23:01.525Z","reserved":null,"kevAdded":[],"kevDue":[]},"cvss":{"headline":{"score":5.5,"severity":"medium","version":"3.1","versionLabel":"v3.1","source":"CVE.org","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","computed":false,"selection":"backend-summary"},"metrics":[{"version":"3.1","versionLabel":"v3.1","source":"CVE.org","score":5.5,"severity":"medium","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","exploitability":null,"impact":null,"computed":false},{"version":"4.0","versionLabel":"v4.0","source":"OSV · Pypi","score":5.7,"severity":"medium","vector":"CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","exploitability":null,"impact":null,"computed":true},{"version":"3.1","versionLabel":"v3.1","source":"OSV · Pypi","score":5.5,"severity":"medium","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","exploitability":4.6,"impact":6,"computed":true},{"version":"3.1","versionLabel":"v3.1","source":"NVD","score":5.5,"severity":"medium","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H","exploitability":null,"impact":null,"computed":false},{"version":"2.0","versionLabel":"v2.0","source":"NVD","score":2.1,"severity":"low","vector":"AV:L/AC:L/Au:N/C:N/I:N/A:P","exploitability":null,"impact":null,"computed":false}]},"epss":{"probability":0.00152,"percentile":0.03963,"severity":"low","asOf":"2026-10-18T00:00:00.000Z","change":{"pp":0,"baselineDate":"2026-09-18T00:00:00.000Z","baselineScore":0.00152},"history":[{"date":"2026-09-14T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-15T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-16T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-17T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-18T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-19T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-20T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-21T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-22T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-23T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-24T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-25T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-26T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-27T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-28T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-29T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-30T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-01T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-02T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-03T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-04T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-05T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-06T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-07T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-08T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-09T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-10T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-11T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-12T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-13T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-14T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-15T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-16T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-17T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-18T00:00:00.000Z","score":0.00152,"percentile":0.03963}],"last30":[{"date":"2026-09-18T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-19T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-20T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-21T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-22T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-23T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-24T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-25T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-26T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-27T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-28T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-29T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-09-30T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-01T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-02T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-03T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-04T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-05T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-06T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-07T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-08T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-09T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-10T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-11T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-12T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-13T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-14T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-15T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-16T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-17T00:00:00.000Z","score":0.00152,"percentile":null},{"date":"2026-10-18T00:00:00.000Z","score":0.00152,"percentile":0.03963}]},"kev":{"state":"not-listed","entries":[],"listedCount":0,"totalCatalogs":3,"catalogs":[{"source":"cisa","label":"CISA","listed":false,"entry":null},{"source":"enisa","label":"ENISA","listed":false,"entry":null},{"source":"circl","label":"CIRCL","listed":false,"entry":null}]},"ransomware":{"state":"none-recorded","sources":[]},"exploits":[],"exploitCount":0,"weaknesses":[{"id":"CWE-369","name":"Divide By Zero","description":"The product divides a value by zero.","type":"weakness","status":"Draft","abstraction":"Base","likelihoodOfExploit":"Medium","url":"https://cwe.mitre.org/data/definitions/369.html"}],"affected":[{"vendor":"google","product":"tensorflow","name":"tensorflow","label":"tensorflow","ecosystem":null,"cpePart":"a","purl":null,"purlType":null,"versions":[{"text":"≥ 2.3.0, < 2.3.4","noFixRecorded":false,"fixedIn":null},{"text":"≥ 2.4.0, < 2.4.3","noFixRecorded":false,"fixedIn":null},{"text":"2.5.0","noFixRecorded":false,"fixedIn":null},{"text":"2.6.0:rc0","noFixRecorded":false,"fixedIn":null},{"text":"2.6.0:rc1","noFixRecorded":false,"fixedIn":null},{"text":"2.6.0:rc2","noFixRecorded":false,"fixedIn":null}],"versionsText":"≥ 2.3.0, < 2.3.4 | ≥ 2.4.0, < 2.4.3 | 2.5.0 | 2.6.0:rc0 | 2.6.0:rc1 | 2.6.0:rc2","eol":null,"hubHref":"/vendor/google/tensorflow"},{"vendor":"PyPI","product":"tensorflow","name":"tensorflow","label":"tensorflow","ecosystem":"PyPI","cpePart":null,"purl":"pkg:pypi/tensorflow","purlType":"pypi","versions":[{"text":"< 2.3.4","noFixRecorded":false,"fixedIn":null},{"text":"≥ 2.5.0, < 2.5.1","noFixRecorded":false,"fixedIn":null},{"text":"< 4923de56ec94fff7770df259ab7f2288a74feb41","noFixRecorded":false,"fixedIn":null},{"text":"≥ 2.4.0, < 2.4.3","noFixRecorded":false,"fixedIn":null}],"versionsText":"< 2.3.4 | ≥ 2.5.0, < 2.5.1 | < 4923de56ec94fff7770df259ab7f2288a74feb41 | ≥ 2.4.0, < 2.4.3","eol":null,"hubHref":null},{"vendor":"PyPI","product":"tensorflow-cpu","name":"tensorflow-cpu","label":"tensorflow-cpu","ecosystem":"PyPI","cpePart":null,"purl":"pkg:pypi/tensorflow-cpu","purlType":"pypi","versions":[{"text":"< 2.3.4","noFixRecorded":false,"fixedIn":null},{"text":"≥ 2.5.0, < 2.5.1","noFixRecorded":false,"fixedIn":null},{"text":"< 4923de56ec94fff7770df259ab7f2288a74feb41","noFixRecorded":false,"fixedIn":null},{"text":"≥ 2.4.0, < 2.4.3","noFixRecorded":false,"fixedIn":null}],"versionsText":"< 2.3.4 | ≥ 2.5.0, < 2.5.1 | < 4923de56ec94fff7770df259ab7f2288a74feb41 | ≥ 2.4.0, < 2.4.3","eol":null,"hubHref":null},{"vendor":"PyPI","product":"tensorflow-gpu","name":"tensorflow-gpu","label":"tensorflow-gpu","ecosystem":"PyPI","cpePart":null,"purl":"pkg:pypi/tensorflow-gpu","purlType":"pypi","versions":[{"text":"< 2.3.4","noFixRecorded":false,"fixedIn":null},{"text":"≥ 2.5.0, < 2.5.1","noFixRecorded":false,"fixedIn":null},{"text":"< 4923de56ec94fff7770df259ab7f2288a74feb41","noFixRecorded":false,"fixedIn":null},{"text":"≥ 2.4.0, < 2.4.3","noFixRecorded":false,"fixedIn":null}],"versionsText":"< 2.3.4 | ≥ 2.5.0, < 2.5.1 | < 4923de56ec94fff7770df259ab7f2288a74feb41 | ≥ 2.4.0, < 2.4.3","eol":null,"hubHref":null},{"vendor":"tensorflow","product":"tensorflow","name":"tensorflow","label":"tensorflow","ecosystem":null,"cpePart":"a","purl":null,"purlType":null,"versions":[{"text":"< 2.5.1","noFixRecorded":false,"fixedIn":null}],"versionsText":"< 2.5.1","eol":null,"hubHref":"/vendor/tensorflow/tensorflow"}],"affectedCount":5,"eol":{"hasEol":false,"count":0},"references":[{"url":"https://github.com/tensorflow/tensorflow/security/advisories/GHSA-95xm-g58g-3p88","label":"github.com/tensorflow/tensorflow/security/advisories/GHSA-95xm-g58g-3p88","hostname":"github.com","tags":["X Refsource CONFIRM","WEB","Advisory","Third Party Advisory"]},{"url":"https://github.com/tensorflow/tensorflow/commit/4923de56ec94fff7770df259ab7f2288a74feb41","label":"github.com/tensorflow/tensorflow/commit/4923de56ec94fff7770df259ab7f2288a74feb41","hostname":"github.com","tags":["X Refsource MISC","WEB","FIX","Patch","Third Party Advisory"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2021-37640","label":"nvd.nist.gov/vuln/detail/CVE-2021-37640","hostname":"nvd.nist.gov","tags":["Advisory"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-cpu/PYSEC-2021-553.yaml","label":"github.com/pypa/advisory-database/tree/main/vulns/tensorflow-cpu/PYSEC-2021-553.yaml","hostname":"github.com","tags":["WEB"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-gpu/PYSEC-2021-751.yaml","label":"github.com/pypa/advisory-database/tree/main/vulns/tensorflow-gpu/PYSEC-2021-751.yaml","hostname":"github.com","tags":["WEB"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow/PYSEC-2021-262.yaml","label":"github.com/pypa/advisory-database/tree/main/vulns/tensorflow/PYSEC-2021-262.yaml","hostname":"github.com","tags":["WEB"]},{"url":"https://github.com/tensorflow/tensorflow","label":"github.com/tensorflow/tensorflow","hostname":"github.com","tags":["PACKAGE"]}],"lineage":{"upstream":[],"downstream":["OPENSUSE-SU-2022:10014-1"],"duplicates":[],"related":["OPENSUSE-SU-2022:10014-1"]},"timeline":[{"kind":"published","date":"2021-08-12T17:35:11.000Z","label":"Published","detail":"Vulnerability first disclosed.","source":null},{"kind":"modified","date":"2024-08-04T01:23:01.525Z","label":"Last modified","detail":"Vulnerability information updated.","source":null}],"risk":{"score":22,"level":"low","profile":"Default","thresholds":{"critical":75,"high":50,"medium":25,"low":10}},"meta":{"dataAsOf":"2026-10-19T12:12:31.554Z","stale":false,"partial":false}}