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
이 취약점은 TensorFlow의 TFLite 모델 생성 과정에서 발생합니다. TFLite 모델을 만들 때 사용되는
TfLiteIntArrayCreate함수에서 발생합니다.TfLiteIntArrayCreate함수는TfLiteIntArray구조체를 동적으로 할당합니다. 그러나TfLiteIntArrayGetSizeInBytes함수에서 반환되는 크기가int자료형으로 반환되어, 모델 입력 데이터에 따라computed_size값이int자료형의 최대값을 넘어서게 되면, 할당된 메모리 공간을 초과하여 정수 오버플로우가 발생합니다.이 취약점은 TensorFlow 2.5.3, 2.6.3, 2.7.1 및 2.8.0 버전에서 발견되었으며, TensorFlow 2.8.0에서 패치되었습니다. 이 패치는 TensorFlow 2.7.1, 2.6.3 및 2.5.3에도 적용됩니다.
취약점을 해결하기 위해서는
TfLiteIntArrayGetSizeInBytes함수에서 반환되는 값의 자료형을size_t로 변경하여 오버플로우를 방지하도록 수정해야 합니다. 패치된 코드는 아래와 같습니다.csize_t TfLiteIntArrayGetSizeInBytes(int size) { static TfLiteIntArray dummy; size_t 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; }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.