CVE-2022-23558: Integer overflow in TFLite array creation
Impact An attacker can craft a TFLite model that would cause an integer overflow in TfLiteIntArrayCreate:
cc TfLiteIntArray TfLiteIntArrayCreate(int size) { int allocsize = TfLiteIntArrayGetSizeInBytes(size); // ... TfLiteIntArray ret = (TfLiteIntArray)malloc(allocsize); // ... }
The TfLiteIntArrayGetSizeInBytes returns an int instead of a sizet:
cc int TfLiteIntArrayGetSizeInBytes(int size) { static TfLiteIntArray dummy;
int computedsize = sizeof(dummy) + sizeof(dummy.data[0]) size; #if defined(MSCVER) // Context for why this is needed is in http://b/189926408#comment21 computedsize -= sizeof(dummy.data[0]); #endif return computedsize; }
An attacker can control model inputs such that computedsize overflows the size of int datatype.
Patches We have patched the issue in GitHub commit a1e1511dde36b3f8aa27a6ec630838e7ea40e091.
The fix will be included in TensorFlow 2.8.0. We will also cherrypick this commit on TensorFlow 2.7.1, TensorFlow 2.6.3, and TensorFlow 2.5.3, 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 Wang Xuan of Qihoo 360 AIVul Team.
Other sources
Tensorflow is an Open Source Machine Learning Framework. An attacker can craft a TFLite model that would cause an integer overflow in TfLiteIntArrayCreate. The TfLiteIntArrayGetSizeInBytes returns an int instead of a sizet. An attacker can control model inputs such that computedsize overflows the size of int datatype. The fix will be included in TensorFlow 2.8.0. We will also cherrypick this commit on TensorFlow 2.7.1, TensorFlow 2.6.3, and TensorFlow 2.5.3, as these are also affected and still in supported range.
Affected Software
Remediation
Event History
Frequently Asked Questions
What is the severity of CVE-2022-23558?
CVE-2022-23558 is classified as a medium severity vulnerability due to the potential for integer overflow.
How do I fix CVE-2022-23558?
To fix CVE-2022-23558, upgrade to TensorFlow versions 2.5.3, 2.6.3, or 2.7.1.
What versions of TensorFlow are affected by CVE-2022-23558?
CVE-2022-23558 affects TensorFlow versions up to 2.5.2, between 2.6.0 and 2.6.2, and exactly 2.7.0.
What is the nature of the vulnerability described in CVE-2022-23558?
CVE-2022-23558 involves an integer overflow that can be exploited through specially crafted TFLite models.
Are TensorFlow GPU and CPU packages also affected by CVE-2022-23558?
Yes, both TensorFlow GPU and CPU packages are affected by CVE-2022-23558 if running the vulnerable versions.