Dataset Viewer

The dataset viewer is not available because its heuristics could not detect any supported data files. You can try uploading some data files, or configuring the data files location manually.

YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

whisper.cpp GGML loader stack-buffer-overflow WRITE

Vulnerability

CWE-787: Out-of-bounds Write (Stack) in whisper.cpp GGML model loader (whisper.cpp).

The weight loading loop uses a fixed 4-element stack array ne[4] but iterates n_dims times (file-controlled) writing to it:

// whisper.cpp:1883-1887
int32_t ne[4] = { 1, 1, 1, 1 };
for (int i = 0; i < n_dims; ++i) {
    read_safe(loader, ne[i]);    // OOB WRITE when i >= 4
    nelements *= ne[i];
}

ASAN Trace

ERROR: AddressSanitizer: stack-buffer-overflow
WRITE of size 4 at 0x...
  #0 memcpy (sanitizer interceptor)
  #1 read_safe<int> whisper.cpp:964
  #2 whisper_model_load whisper.cpp:1885
  #3 whisper_init_with_params_no_state whisper.cpp:3730
  #4 whisper_init_from_file_with_params whisper.cpp:3750
Address is located in stack of thread T0 at offset 1984 in frame
  #0 whisper_model_load whisper.cpp:1485

Additional Bugs

  1. whisper.cpp:1583: filters.n_mel * filters.n_fft int32 overflow in resize()
  2. whisper.cpp:1886: nelements *= ne[i] signed int32 overflow
  3. whisper.cpp:5026: Same n_dims OOB in VAD model loading path

Reproduction

git clone --depth=1 https://github.com/ggerganov/whisper.cpp.git && cd whisper.cpp
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  -DCMAKE_CXX_FLAGS="-fsanitize=address -fno-omit-frame-pointer" \
  -DCMAKE_C_FLAGS="-fsanitize=address -fno-omit-frame-pointer" \
  -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address" \
  -DCMAKE_SHARED_LINKER_FLAGS="-fsanitize=address" \
  -DWHISPER_BUILD_TESTS=OFF -DWHISPER_BUILD_EXAMPLES=OFF \
  -DGGML_NATIVE=OFF
make -j$(nproc) whisper
g++ -fsanitize=address -fno-omit-frame-pointer -O1 -g \
  -I../include -I../ggml/include harness.cpp \
  -Lsrc -lwhisper -Wl,-rpath,src -lpthread -o harness
python3 craft_malicious_whisper.py
./harness malicious_whisper.bin   # stack-buffer-overflow WRITE

Fix

Check n_dims <= 4 (or GGML_MAX_DIMS) before entering the loop.

Downloads last month
46