5.5medium
Crash in NMS ops caused by integer conversion to unsigned in TensorFlow
- Severity
- 5.5medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.17% (higher than 6% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-vmjw-c2vp-p33cBIT-TENSORFLOW-2021-37669PYSEC-2021-291PYSEC-2021-582PYSEC-2021-780
Description
TensorFlow is an end-to-end open source platform for machine learning. In affected versions an attacker can cause denial of service in applications serving models using `tf.raw_ops.NonMaxSuppressionV5` by triggering a division by 0. The [implementation](https://github.com/tensorflow/tensorflow/blob/460e000de3a83278fb00b61a16d161b1964f15f4/tensorflow/core/kernels/image/non_max_suppression_op.cc#L170-L271) uses a user controlled argument to resize a `std::vector`. However, as `std::vector::resize` takes the size argument as a `size_t` and `output_size` is an `int`, there is an implicit conversion to unsigned. If the attacker supplies a negative value, this conversion results in a crash. A similar issue occurs in `CombinedNonMaxSuppression`. We have patched the issue in GitHub commit 3a7362750d5c372420aa8f0caf7bf5b5c3d0f52d and commit [b5cdbf12ffcaaffecf98f22a6be5a64bb96e4f58. The fix will be included in TensorFlow 2.6.0. We will also cherrypick this commit on TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.4, as these are also affected and still in supported range.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| tensorflow tensorflow | >= 2.5.0, < 2.5.1, >= 2.4.0, < 2.4.3, < 2.3.4 | CVE List |
| tensorflow (PyPI) | before 2.3.4, from 2.4.0 before 2.4.3, from 2.5.0 before 2.5.1, before 3a7362750d5c372420aa8f0caf7bf5b5c3d0f52d, before b5cdbf12ffcaaffecf98f22a6be5a64bb96e4f58, from 2.3.0 before 2.3.4 | GitHub Advisory Database, PyPA Advisory Database |
| tensorflow-cpu (PyPI) | before 2.3.4, from 2.4.0 before 2.4.3, from 2.5.0 before 2.5.1, before 3a7362750d5c372420aa8f0caf7bf5b5c3d0f52d, before b5cdbf12ffcaaffecf98f22a6be5a64bb96e4f58, from 2.3.0 before 2.3.4 | GitHub Advisory Database, PyPA Advisory Database |
| tensorflow-gpu (PyPI) | before 2.3.4, from 2.4.0 before 2.4.3, from 2.5.0 before 2.5.1, before 3a7362750d5c372420aa8f0caf7bf5b5c3d0f52d, before b5cdbf12ffcaaffecf98f22a6be5a64bb96e4f58, from 2.3.0 before 2.3.4 | GitHub Advisory Database, PyPA Advisory Database |
| google tensorflow | from 2.3.0 before 2.3.4, from 2.4.0 before 2.4.3, 2.5.0, 2.6.0 | NVD |
| tensorflow (Bitnami) | from 2.3.0 before 2.3.4, from 2.4.0 before 2.4.3, from 2.5.0 before 2.5.1 | Bitnami Vulnerability Database |
All scores
| GitHub_M | 5.5medium CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H |
| GitHub | 5.5medium CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H |
| GitHub | medium CVSS:4.0 | CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N |
| NVD | 5.5medium CVSS:3.1 | CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H |
| NVD | 2.1low CVSS:2.0 | AV:L/AC:L/Au:N/C:N/I:N/A:P |
| Bitnami Vulnerability Database | medium rating |
Classification
What each source says
CVE List
TensorFlow is an end-to-end open source platform for machine learning. In affected versions an attacker can cause denial of service in applications serving models using `tf.raw_ops.NonMaxSuppressionV5` by triggering a division by 0. The [implementation](https://github.com/tensorflow/tensorflow/blob/460e000de3a83278fb00b61a16d161b1964f15f4/tensorflow/core/kernels/image/non_max_suppression_op.cc#L170-L271) uses a user controlled argument to resize a `std::vector`. However, as `std::vector::resize` takes the size argument as a `size_t` and `output_size` is an `int`, there is an implicit conversion to unsigned. If the attacker supplies a negative value, this conversion results in a crash. A similar issue occurs in `CombinedNonMaxSuppression`. We have patched the issue in GitHub commit 3a7362750d5c372420aa8f0caf7bf5b5c3d0f52d and commit [b5cdbf12ffcaaffecf98f22a6be5a64bb96e4f58. The fix will be included in TensorFlow 2.6.0. We will also cherrypick this commit on TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.4, as these are also affected and still in supported range.
GitHub Advisory Database
Impact
An attacker can cause denial of service in applications serving models using tf.raw_ops.NonMaxSuppressionV5 by triggering a division by 0:
import tensorflow as tf
tf.raw_ops.NonMaxSuppressionV5(
boxes=[[0.1,0.1,0.1,0.1],[0.2,0.2,0.2,0.2],[0.3,0.3,0.3,0.3]],
scores=[1.0,2.0,3.0],
max_output_size=-1,
iou_threshold=0.5,
score_threshold=0.5,
soft_nms_sigma=1.0,
pad_to_max_output_size=True)
The implementation uses a user controlled argument to resize a std::vector:
const int output_size = max_output_size.scalar<int>()();
// ...
std::vector<int> selected;
// ...
if (pad_to_max_output_size) {
selected.resize(output_size, 0);
// ...
}
However, as std::vector::resize takes the size argument as a size_t and output_size is an int, there is an implicit conversion to usigned. If the attacker supplies a negative value, this conversion results in a crash.
A similar issue occurs in CombinedNonMaxSuppression:
import tensorflow as tf
tf.raw_ops.NonMaxSuppressionV5(
boxes=[[[[0.1,0.1,0.1,0.1],[0.2,0.2,0.2,0.2],[0.3,0.3,0.3,0.3]],[[0.1,0.1,0.1,0.1],[0.2,0.2,0.2,0.2],[0.3,0.3,0.3,0.3]],[[0.1,0.1,0.1,0.1],[0.2,0.2,0.2,0.2],[0.3,0.3,0.3,0.3]]]],
scores=[[[1.0,2.0,3.0],[1.0,2.0,3.0],[1.0,2.0,3.0]]],
max_output_size_per_class=-1,
max_total_size=10,
iou_threshold=score_threshold=0.5,
pad_per_class=True,
clip_boxes=True)
Patches
We have patched the issue in GitHub commit 3a7362750d5c372420aa8f0caf7bf5b5c3d0f52d and commit b5cdbf12ffcaaffecf98f22a6be5a64bb96e4f58.
The fix will be included in TensorFlow 2.6.0. We will also cherrypick this commit on TensorFlow 2.5.1, TensorFlow 2.4.3, and TensorFlow 2.3.4, as these are also affected and still in supported range.
For more information
Please consult our security guide for more information regarding the security model and how to contact us with issues and questions.
Attribution
This vulnerability has been reported by members of the Aivul Team from Qihoo 360.
NVD (es)
TensorFlow es una plataforma de código abierto de extremo a extremo para el aprendizaje automático. En las versiones afectadas, un atacante puede causar una denegación de servicio en aplicaciones que sirven modelos que usan "tf.raw_ops.NonMaxSuppressionV5" al activar una división por 0. La [implementación] (https://github.com/tensorflow/tensorflow/blob/460e000de3a83278fb00b61a16d161b1964f15f4/ tensorflow / core / kernels / image / non_max_suppression_op.cc # L170-L271) usa un argumento controlado por el usuario para cambiar el tamaño de un "std :: vector". Sin embargo, como "std :: vector :: resize" toma el argumento de tamaño como un" size_t" y "output_size" es un" int", hay una conversión implícita a unsigned. Si el atacante proporciona un valor negativo, esta conversión resulta en un bloqueo. Un problema similar ocurre en "CombinedNonMaxSuppression". Hemos solucionado el problema en GitHub, commit 3a7362750d5c372420aa8f0caf7bf5b5c3d0f52d y commit [b5cdbf12ffcaaffecf98f22a6be5a64bb96e4f58. La corrección será incluida en TensorFlow versión 2.6.0. También seleccionaremos este commit en TensorFlow versión 2.5.1, TensorFlow versión 2.4.3 y TensorFlow versión 2.3.4, ya que estos también están afectados y aún se encuentran en el rango admitido.
References
| https://github.com/tensorflow/tensorflow/security/advisories/GHSA-vmjw-c2vp-p33c | advisory, third-party-advisory, web | |
| https://github.com/tensorflow/tensorflow/commit/3a7362750d5c372420aa8f0caf7bf5b5c3d0f52d | advisory, fix, patch, third-party-advisory, web | |
| https://github.com/tensorflow/tensorflow/commit/b5cdbf12ffcaaffecf98f22a6be5a64bb96e4f58 | advisory, fix, patch, third-party-advisory, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2021-37669 | advisory, web | |
| https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-cpu/PYSEC-2021-582.yaml | web | |
| https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-gpu/PYSEC-2021-780.yaml | web | |
| https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow/PYSEC-2021-291.yaml | web | |
| https://github.com/tensorflow/tensorflow | web | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2021-37669 changed 2024-08-04 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-vmjw-c2vp-p33c changed 2026-07-08 | CC-BY-4.0 |
| NVD | CVE-2021-37669 changed 2026-06-17 | Public domain |
| PyPA Advisory Database | PYSEC-2021-291 changed 2023-12-06 | CC-BY-4.0 |
| PyPA Advisory Database | PYSEC-2021-582 changed 2023-12-06 | CC-BY-4.0 |
| PyPA Advisory Database | PYSEC-2021-780 changed 2023-12-06 | CC-BY-4.0 |
| Bitnami Vulnerability Database | BIT-TENSORFLOW-2021-37669 changed 2026-09-08 | Apache-2.0 |