ghsa-h6q3-vv32-2cq5
Vulnerability from github
Impact
The reference kernel of the CONV_3D_TRANSPOSE
TensorFlow Lite operator wrongly increments the data_ptr when adding the bias to the result.
Instead 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.
An 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).
```python
import tensorflow as tf
model = tf.keras.Sequential(
[
tf.keras.layers.InputLayer(input_shape=(2, 2, 2, 1024), batch_size=1),
tf.keras.layers.Conv3DTranspose(
filters=8,
kernel_size=(2, 2, 2),
padding="same",
data_format="channels_last",
),
]
)
converter = tf.lite.TFLiteConverter.from_keras_model(model) tflite_model = converter.convert()
interpreter = tf.lite.Interpreter( model_content=tflite_model, experimental_op_resolver_type=tf.lite.experimental.OpResolverType.BUILTIN_REF, )
interpreter.allocate_tensors() interpreter.set_tensor( interpreter.get_input_details()[0]["index"], tf.zeros(shape=[1, 2, 2, 2, 1024]) ) interpreter.invoke() ```
Patches
We have patched the issue in GitHub commit 72c0bdcb25305b0b36842d746cc61d72658d2941.
The 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.
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 Thibaut Goetghebuer-Planchon, Arm Ltd.
{ "affected": [ { "package": { "ecosystem": "PyPI", "name": "tensorflow" }, "ranges": [ { "events": [ { "introduced": "0" }, { "fixed": "2.8.4" } ], "type": "ECOSYSTEM" } ] }, { "package": { "ecosystem": "PyPI", "name": "tensorflow" }, "ranges": [ { "events": [ { "introduced": "2.9.0" }, { "fixed": "2.9.3" } ], "type": "ECOSYSTEM" } ] }, { "package": { "ecosystem": "PyPI", "name": "tensorflow" }, "ranges": [ { "events": [ { "introduced": "2.10.0" }, { "fixed": "2.10.1" } ], "type": "ECOSYSTEM" } ] } ], "aliases": [ "CVE-2022-41894" ], "database_specific": { "cwe_ids": [ "CWE-120" ], "github_reviewed": true, "github_reviewed_at": "2022-11-21T20:44:24Z", "nvd_published_at": "2022-11-18T22:15:00Z", "severity": "HIGH" }, "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 \u003e 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", "id": "GHSA-h6q3-vv32-2cq5", "modified": "2022-11-21T20:44:24Z", "published": "2022-11-21T20:44:24Z", "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" } ], "schema_version": "1.4.0", "severity": [ { "score": "CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:H/I:H/A:H", "type": "CVSS_V3" } ], "summary": "Buffer overflow in `CONV_3D_TRANSPOSE` on TFLite" }
Sightings
Author | Source | Type | Date |
---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
- Confirmed: The vulnerability is confirmed from an analyst perspective.
- Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
- Patched: This vulnerability was successfully patched by the user reporting the sighting.
- Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
- Not confirmed: The user expresses doubt about the veracity of the vulnerability.
- Not patched: This vulnerability was not successfully patched by the user reporting the sighting.