CVE-2021-37652: Use after free in boosted trees creation in TensorFlow
Impact The implementation for tf.rawops.BoostedTreesCreateEnsemble can result in a use after free error if an attacker supplies specially crafted arguments:
python import tensorflow as tf
v= tf.Variable([0.0]) tf.rawops.BoostedTreesCreateEnsemble( treeensemblehandle=v.handle, stamptoken=[0], treeensembleserialized=['0'])
The implementation uses a reference counted resource and decrements the refcount if the initialization fails, as it should. However, when the code was written, the resource was represented as a naked pointer but later refactoring has changed it to be a smart pointer. Thus, when the pointer leaves the scope, a subsequent free-ing of the resource occurs, but this fails to take into account that the refcount has already reached 0, thus the resource has been already freed. During this double-free process, members of the resource object are accessed for cleanup but they are invalid as the entire resource has been freed.
Patches We have patched the issue in GitHub commit 5ecec9c6fbdbc6be03295685190a45e7eee726ab.
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.
Other sources
TensorFlow is an end-to-end open source platform for machine learning. In affected versions the implementation for tf.rawops.BoostedTreesCreateEnsemble can result in a use after free error if an attacker supplies specially crafted arguments. The implementation uses a reference counted resource and decrements the refcount if the initialization fails, as it should. However, when the code was written, the resource was represented as a naked pointer but later refactoring has changed it to be a smart pointer. Thus, when the pointer leaves the scope, a subsequent free-ing of the resource occurs, but this fails to take into account that the refcount has already reached 0, thus the resource has been already freed. During this double-free process, members of the resource object are accessed for cleanup but they are invalid as the entire resource has been freed. We have patched the issue in GitHub commit 5ecec9c6fbdbc6be03295685190a45e7eee726ab. 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 Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/tensorflow-gputo a version that resolves this vulnerability.Fixed in 2.5.1 - Upgrade
Upgrade
pip/tensorflow-gputo a version that resolves this vulnerability.Fixed in 2.4.3 - Upgrade
Upgrade
pip/tensorflow-gputo a version that resolves this vulnerability.Fixed in 2.3.4 - Upgrade
Upgrade
pip/tensorflow-cputo a version that resolves this vulnerability.Fixed in 2.5.1 - Upgrade
Upgrade
pip/tensorflow-cputo a version that resolves this vulnerability.Fixed in 2.4.3 - Upgrade
Upgrade
pip/tensorflow-cputo a version that resolves this vulnerability.Fixed in 2.3.4 - Upgrade
Upgrade
pip/tensorflowto a version that resolves this vulnerability.Fixed in 2.5.1 - Upgrade
Upgrade
pip/tensorflowto a version that resolves this vulnerability.Fixed in 2.4.3 - Upgrade
Upgrade
pip/tensorflowto a version that resolves this vulnerability.Fixed in 2.3.4 - Upgrade
Upgrade
tensorflow/tf.raw_ops.BoostedTreesCreateEnsembleto a version that resolves this vulnerability.Fixed in 2.6.0Patch 5ecec9c6fbdbc6be03295685190a45e7eee726ab - Upgrade
Upgrade
tensorflow/tf.raw_ops.BoostedTreesCreateEnsembleto a version that resolves this vulnerability.Fixed in 2.5.1Patch 5ecec9c6fbdbc6be03295685190a45e7eee726ab - Upgrade
Upgrade
tensorflow/tf.raw_ops.BoostedTreesCreateEnsembleto a version that resolves this vulnerability.Fixed in 2.4.3Patch 5ecec9c6fbdbc6be03295685190a45e7eee726ab - Upgrade
Upgrade
tensorflow/tf.raw_ops.BoostedTreesCreateEnsembleto a version that resolves this vulnerability.Fixed in 2.3.4Patch 5ecec9c6fbdbc6be03295685190a45e7eee726ab
Event History
Frequently Asked Questions
What is the severity of CVE-2021-37652?
CVE-2021-37652 has been classified as a high severity vulnerability due to the potential for exploitation via use after free errors.
How do I fix CVE-2021-37652?
To mitigate CVE-2021-37652, upgrade to TensorFlow version 2.5.1 or later, or to versions 2.4.3 or 2.3.4 as specified in the remediation guidance.
Which TensorFlow versions are affected by CVE-2021-37652?
CVE-2021-37652 impacts TensorFlow versions 2.3.0 to 2.3.4, 2.4.0 to 2.4.3, and specific release candidates of 2.6.0.
What happens if I do not address CVE-2021-37652?
Failure to address CVE-2021-37652 may leave systems vulnerable to attacks that exploit the use after free error, potentially leading to data corruption or unauthorized access.
Is CVE-2021-37652 specific to any platform?
CVE-2021-37652 affects the Google TensorFlow library across different platforms but is notably relevant for installations of TensorFlow through pip.