ghsa-9gwq-6cwj-47h3
Vulnerability from github
7.2 (High) - CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:H/SC:N/SI:N/SA:N
Impact
An attacker can craft a TFLite model that would cause an integer overflow in TfLiteIntArrayCreate
:
cc
TfLiteIntArray* TfLiteIntArrayCreate(int size) {
int alloc_size = TfLiteIntArrayGetSizeInBytes(size);
// ...
TfLiteIntArray* ret = (TfLiteIntArray*)malloc(alloc_size);
// ...
}
The TfLiteIntArrayGetSizeInBytes
returns an int
instead of a size_t
:
```cc int TfLiteIntArrayGetSizeInBytes(int size) { static TfLiteIntArray dummy;
int computed_size = sizeof(dummy) + sizeof(dummy.data[0]) * size;
if defined(_MSC_VER)
// Context for why this is needed is in http://b/189926408#comment21 computed_size -= sizeof(dummy.data[0]);
endif
return computed_size; } ```
An attacker can control model inputs such that computed_size
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.
{ "affected": [ { "package": { "ecosystem": "PyPI", "name": "tensorflow" }, "ranges": [ { "events": [ { "introduced": "0" }, { "fixed": "2.5.3" } ], "type": "ECOSYSTEM" } ] }, { "package": { "ecosystem": "PyPI", "name": "tensorflow" }, "ranges": [ { "events": [ { "introduced": "2.6.0" }, { "fixed": "2.6.3" } ], "type": "ECOSYSTEM" } ] }, { "package": { "ecosystem": "PyPI", "name": "tensorflow" }, "ranges": [ { "events": [ { "introduced": "2.7.0" }, { "fixed": "2.7.1" } ], "type": "ECOSYSTEM" } ], "versions": [ "2.7.0" ] }, { "package": { "ecosystem": "PyPI", "name": "tensorflow-cpu" }, "ranges": [ { "events": [ { "introduced": "0" }, { "fixed": "2.5.3" } ], "type": "ECOSYSTEM" } ] }, { "package": { "ecosystem": "PyPI", "name": "tensorflow-cpu" }, "ranges": [ { "events": [ { "introduced": "2.6.0" }, { "fixed": "2.6.3" } ], "type": "ECOSYSTEM" } ] }, { "package": { "ecosystem": "PyPI", "name": "tensorflow-cpu" }, "ranges": [ { "events": [ { "introduced": "2.7.0" }, { "fixed": "2.7.1" } ], "type": "ECOSYSTEM" } ], "versions": [ "2.7.0" ] }, { "package": { "ecosystem": "PyPI", "name": "tensorflow-gpu" }, "ranges": [ { "events": [ { "introduced": "0" }, { "fixed": "2.5.3" } ], "type": "ECOSYSTEM" } ] }, { "package": { "ecosystem": "PyPI", "name": "tensorflow-gpu" }, "ranges": [ { "events": [ { "introduced": "2.6.0" }, { "fixed": "2.6.3" } ], "type": "ECOSYSTEM" } ] }, { "package": { "ecosystem": "PyPI", "name": "tensorflow-gpu" }, "ranges": [ { "events": [ { "introduced": "2.7.0" }, { "fixed": "2.7.1" } ], "type": "ECOSYSTEM" } ], "versions": [ "2.7.0" ] } ], "aliases": [ "CVE-2022-23558" ], "database_specific": { "cwe_ids": [ "CWE-190" ], "github_reviewed": true, "github_reviewed_at": "2022-02-03T20:30:33Z", "nvd_published_at": "2022-02-04T23:15:00Z", "severity": "HIGH" }, "details": "### Impact \nAn attacker can craft a TFLite model that would cause an integer overflow [in `TfLiteIntArrayCreate`](https://github.com/tensorflow/tensorflow/blob/ca6f96b62ad84207fbec580404eaa7dd7403a550/tensorflow/lite/c/common.c#L53-L60):\n\n```cc\nTfLiteIntArray* TfLiteIntArrayCreate(int size) {\n int alloc_size = TfLiteIntArrayGetSizeInBytes(size);\n // ...\n TfLiteIntArray* ret = (TfLiteIntArray*)malloc(alloc_size);\n // ...\n} \n```\n\nThe [`TfLiteIntArrayGetSizeInBytes`](https://github.com/tensorflow/tensorflow/blob/ca6f96b62ad84207fbec580404eaa7dd7403a550/tensorflow/lite/c/common.c#L24-L33) returns an `int` instead of a `size_t`:\n\n```cc\nint TfLiteIntArrayGetSizeInBytes(int size) {\n static TfLiteIntArray dummy;\n\n int computed_size = sizeof(dummy) + sizeof(dummy.data[0]) * size;\n#if defined(_MSC_VER)\n // Context for why this is needed is in http://b/189926408#comment21\n computed_size -= sizeof(dummy.data[0]);\n#endif\n return computed_size;\n}\n```\n\nAn attacker can control model inputs such that `computed_size` overflows the size of `int` datatype.\n\n### Patches\nWe have patched the issue in GitHub commit [a1e1511dde36b3f8aa27a6ec630838e7ea40e091](https://github.com/tensorflow/tensorflow/commit/a1e1511dde36b3f8aa27a6ec630838e7ea40e091).\n\nThe 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.\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### Attribution\nThis vulnerability has been reported by Wang Xuan of Qihoo 360 AIVul Team.", "id": "GHSA-9gwq-6cwj-47h3", "modified": "2024-11-13T22:36:09Z", "published": "2022-02-09T23:52:24Z", "references": [ { "type": "WEB", "url": "https://github.com/tensorflow/tensorflow/security/advisories/GHSA-9gwq-6cwj-47h3" }, { "type": "ADVISORY", "url": "https://nvd.nist.gov/vuln/detail/CVE-2022-23558" }, { "type": "WEB", "url": "https://github.com/tensorflow/tensorflow/commit/a1e1511dde36b3f8aa27a6ec630838e7ea40e091" }, { "type": "WEB", "url": "https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-cpu/PYSEC-2022-67.yaml" }, { "type": "WEB", "url": "https://github.com/pypa/advisory-database/tree/main/vulns/tensorflow-gpu/PYSEC-2022-122.yaml" }, { "type": "WEB", "url": "https://github.com/tensorflow/tensorflow" }, { "type": "WEB", "url": "https://github.com/tensorflow/tensorflow/blob/ca6f96b62ad84207fbec580404eaa7dd7403a550/tensorflow/lite/c/common.c#L24-L33" }, { "type": "WEB", "url": "https://github.com/tensorflow/tensorflow/blob/ca6f96b62ad84207fbec580404eaa7dd7403a550/tensorflow/lite/c/common.c#L53-L60" } ], "schema_version": "1.4.0", "severity": [ { "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:H", "type": "CVSS_V3" }, { "score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:H/SC:N/SI:N/SA:N", "type": "CVSS_V4" } ], "summary": "Integer overflow in TFLite array creation" }
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.