
Preuve de concept reproductible CVE-2026-36834 démontrant une lecture de tableau hors limites dans le décodeur Panasonic RW2 de LibRaw, avec script de mutation et reproduction du crash basée sur un sanitizer.
Une lecture hors limites de tableau existe dans src/decoders/pana8.cpp. La fonction GetDBit() peut retourner la valeur 17 lorsqu'aucune correspondance de table de Huffman n'est trouvée, mais huff_coeff[] est déclaré avec seulement 17 éléments (indices valides 0-16). Cela entraîne l'accès à huff_coeff[17], déclenchant un comportement indéfini confirmé par UBSan et AddressSanitizer.
Les applications qui traitent des fichiers RW2 fournis par l'utilisateur, telles que les éditeurs d'images ou les outils de gestion de photos utilisant LibRaw, pourraient planter ou potentiellement provoquer une fuite de mémoire du processus en ouvrant un fichier malveillant.
CWE: CWE-125 (Out-of-bounds Read), CWE-129 (Improper Validation of Array Index) CVSS v3.1: AV:L/AC:L/PR:N/UI:R/S:U/C:L/I:N/A:H (~6.5 Medium)
Commit Git : 777f20ae21c611a78021bd051fbbf1e71eae78f2
Fichier : src/decoders/pana8.cpp Fonction : pana8_param_t::DecodeC8()
La cause racine se trouve dans GetDBit() :
uint32_t pana8_param_t::GetDBit(uint64_t a2)
{
for (int i = 0; i < 16; i++)
if ((a2 & hufftable2[i]) == hufftable1[i])
return i;
return uint32_t((hufftable2[16] & a2) == hufftable1[16]) ^ 0x11u;
// When comparison is false: returns 0 ^ 17 = 17
}
La valeur de retour est ensuite utilisée directement comme index de tableau sans vérification des limites :
huff_index = int(GetDBit(pixbits)); // can be 17
int32_t v37 = (huff_coeff[huff_index] >> 24) // line 250: OOB
uint32_t hc = huff_coeff[huff_index]; // line 251: OOB
// ... and lines 254, 273
Chaîne d'appel confirmée (sortie UBSan) LibRaw::unpack() -> panasonicC8_load_raw() pana8.cpp:125 -> pana8_decode_loop() pana8.cpp:132 -> pana8_decode_strip() pana8.cpp:155 -> DecodeC8() pana8.cpp:250 <-- OOB triggered
Erreurs UBSan déclenchées : pana8.cpp:250 index 17 out of bounds for type 'unsigned int [17]' pana8.cpp:251 index 17 out of bounds for type 'unsigned int [17]' pana8.cpp:254 index 17 out of bounds for type 'unsigned int [17]' pana8.cpp:254 shift exponent -17 is negative pana8.cpp:273 index 17 out of bounds for type 'unsigned int [17]' pana8.cpp:303 left shift of negative value -1
Compilez LibRaw avec les sanitizers :
./configure CXXFLAGS="-fsanitize=address,undefined -g -O1" \
LDFLAGS="-fsanitize=address,undefined"
make -j$(nproc)
Exécutez le script de mutation sur n'importe quel fichier RW2 Panasonic :
python3 mutate_rw2.py input.rw2 mutated_pana8.rw2
ASAN_OPTIONS=halt_on_error=0:print_stats=1 ./bin/dcraw_emu -v mutated_pana8.rw2
https://github.com/LibRaw/LibRaw/commit/02da167e0f819a37dbb7d714e87c5b40df6c5917