CVE-2022-41894: Tensorflow Buffer Overflow Vulnerability
HIGHCVE-2022-41894 is a HIGH (CVSS 7.1) buffer overflow vulnerability (CWE-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')) affecting Tensorflow libraries in the PyPI ecosystem. The issue involves buffer overflow in `conv_3d_transpose` on tflite. Remediation is available by upgrading affected packages to version 2.8.4, 2.9.3, 2.10.1.
CVE-2022-41894 at a Glance
Security Impact
CVSS: 7.1
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H).
How to Fix CVE-2022-41894
To remediate this vulnerability, upgrade all affected Tensorflow dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install tensorflow>=2.8.4
pip install tensorflow>=2.9.3
pip install tensorflow>=2.10.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show tensorflow
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2022-41894, inspect your installed packages using pip:
pip show tensorflow
Analyze the terminal output to locate any version of Tensorflow in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.8.4), your application is affected.
Note: The pip show tensorflow command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow'), where the product copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer. In Tensorflow, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2022-41894 Affected Tensorflow Versions
3 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
tensorflow
|
PyPI |
< 2.8.4
|
2.8.4
|
|
tensorflow
|
PyPI |
≥ 2.9.0
< 2.9.3
|
2.9.3
|
|
tensorflow
|
PyPI |
≥ 2.10.0
< 2.10.1
|
2.10.1
|
References
Frequently Asked Questions
What is CVE-2022-41894?
Which Tensorflow versions are affected?
What version fixes CVE-2022-41894?
Is tensorflow affected?
What is the CVSS score of CVE-2022-41894?
What CWE is associated with CVE-2022-41894?
How can I check PyPI dependencies for CVE-2022-41894?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-h6q3-vv32-2cq5",
"modified" : "2022-11-21T20:44:24Z",
"published" : "2022-11-21T20:44:24Z",
"aliases" : [ "CVE-2022-41894" ],
"summary" : "Buffer overflow in `CONV_3D_TRANSPOSE` on TFLite",
"details" : "### Impact\nThe reference kernel of the [`CONV_3D_TRANSPOSE`](https://github.com/tensorflow/tensorflow/blob/091e63f0ea33def7ecad661a5ac01dcafbafa90b/tensorflow/lite/kernels/internal/reference/conv3d_transpose.h#L121) TensorFlow Lite operator wrongly increments the data_ptr when adding the bias to the result.\n\nInstead of `data_ptr += num_channels;` it should be `data_ptr += output_num_channels;` as if the number of input channels is different than the number of output channels, the wrong result will be returned and a buffer overflow will occur if num_channels > output_num_channels.\n\nAn attacker can craft a model with a specific number of input channels in a way similar to the attached example script. It is then possible to write specific values through the bias of the layer outside the bounds of the buffer. This attack only works if the reference kernel resolver is used in the interpreter (i.e. `experimental_op_resolver_type=tf.lite.experimental.OpResolverType.BUILTIN_REF` is used).\n```python\nimport tensorflow as tf\nmodel = tf.keras.Sequential(\n [\n tf.keras.layers.InputLayer(input_shape=(2, 2, 2, 1024), batch_size=1),\n tf.keras.layers.Conv3DTranspose(\n filters=8,\n kernel_size=(2, 2, 2),\n padding=\"same\",\n data_format=\"channels_last\",\n ),\n ]\n)\n\nconverter = tf.lite.TFLiteConverter.from_keras_model(model)\ntflite_model = converter.convert()\n\ninterpreter = tf.lite.Interpreter(\n model_content=tflite_model,\n experimental_op_resolver_type=tf.lite.experimental.OpResolverType.BUILTIN_REF,\n)\n\ninterpreter.allocate_tensors()\ninterpreter.set_tensor(\n interpreter.get_input_details()[0][\"index\"], tf.zeros(shape=[1, 2, 2, 2, 1024])\n)\ninterpreter.invoke()\n```\n\n### Patches\nWe have patched the issue in GitHub commit [72c0bdcb25305b0b36842d746cc61d72658d2941](https://github.com/tensorflow/tensorflow/commit/72c0bdcb25305b0b36842d746cc61d72658d2941).\n\nThe fix will be included in TensorFlow 2.11. We will also cherrypick this commit on TensorFlow 2.10.1, 2.9.3, and TensorFlow 2.8.4, as these are also affected and still in supported range.\n\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\n### Attribution\nThis vulnerability has been reported by Thibaut Goetghebuer-Planchon, Arm Ltd.\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "tensorflow"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.8.4"
} ]
} ]
}, {
"package" : {
"ecosystem" : "PyPI",
"name" : "tensorflow"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.9.0"
}, {
"fixed" : "2.9.3"
} ]
} ]
}, {
"package" : {
"ecosystem" : "PyPI",
"name" : "tensorflow"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.10.0"
}, {
"fixed" : "2.10.1"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/tensorflow/tensorflow/security/advisories/GHSA-h6q3-vv32-2cq5"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-41894"
}, {
"type" : "WEB",
"url" : "https://github.com/tensorflow/tensorflow/commit/72c0bdcb25305b0b36842d746cc61d72658d2941"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/tensorflow/tensorflow"
}, {
"type" : "WEB",
"url" : "https://github.com/tensorflow/tensorflow/blob/091e63f0ea33def7ecad661a5ac01dcafbafa90b/tensorflow/lite/kernels/internal/reference/conv3d_transpose.h#L121"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-120" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2022-11-21T20:44:24Z",
"nvd_published_at" : "2022-11-18T22:15:00Z"
}
}