CVE description: Tensorflow is an Open Source Machine Learning Framework. An attacker…
- User
CVE description: Tensorflow is an Open Source Machine Learning Framework. An attacker can craft a TFLite model that would cause an integer overflow in
TfLiteIntArrayCreate. TheTfLiteIntArrayGetSizeInBytesreturns anintinstead of asize\_t. An attacker can control model inputs such thatcomputed_sizeoverflows the size ofint` 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.취약점 발생 중인 함수: TfLiteIntArray* TfLiteIntArrayCreate(int size) { int alloc_size = TfLiteIntArrayGetSizeInBytes(size); if (alloc_size <= 0) return NULL; TfLiteIntArray* ret = (TfLiteIntArray*)malloc(alloc_size); if (!ret) return ret; ret->size = size; return ret; } 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; }
어디서 취약점이 발생하는지랑 패치 어떻게 해야하는지 알려줘
- Assistant
취약점 발생 원인: 이 취약점은
TfLiteIntArrayGetSizeInBytes함수에서 발생합니다. 함수는int대신size_t를 반환해야 하는데, 공격자가 이를 조작하여computed_size가int데이터 타입의 크기를 오버플로우하게 만들 수 있습니다.패치 방법: 이 취약점을 수정하려면,
TfLiteIntArrayGetSizeInBytes함수가size_t를 반환하도록 변경하고, 반환되는 값에 대한 오버플로우 검사를 추가해야 합니다.- 함수의 반환 타입을
int에서size_t로 변경합니다.
csize_t TfLiteIntArrayGetSizeInBytes(int size);- 오버플로우를 확인하기 위한 검사를 추가합니다. 이를 위해
computed_size를 계산하기 전에 먼저 size와 곱셈을 수행하고 오버플로우를 검사합니다.
c - 함수의 반환 타입을
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.