Skip to content
GoogleGHSA-cmhf-chvw-6c7j

LibRaw: Uninitialized memory disclosure via LibRaw_buffer_datastream::read

HighPublished Oct 22, 2024

### Summary Uninitialized memory disclosure can be achieved by parsing a truncated RAW picture. ### Severity High - It is possible to exploit the vulnerable pattern in multiple ways and it may lead to complete memory reconstruction of the target allocation - whose size is controllable through TIFF tags - by an attacker with access to the bitmap result or the parsed metadata. ### Proof of Concept 1. Compile LibRaw following the instructions on https://github.com/LibRaw/LibRaw/blob/0.21.2/INSTALL 2. Run the `bin/simple_dcraw` sample binary with the provided file: bin/simple_dcraw [poc.bin](https://github.com/google/security-research/blob/master/pocs/LibRaw/UninitializedMemorypoc.bin) ### Further Analysis LibRaw supports a wide range of RAW picture formats. In order to do so, it employs a format recognition system based on which TIFF tags are found in the file. Once a format is recognized, the `load_raw` function pointer - responsible for extracting the raw image from the input file - is populated with the appropriate handler. Such functions commonly use `LibRaw_buffer_datastream::read` to read from the input buffer, which is semantically equivalent to libc’s [fread](https://linux....

GitHub advisory

Affected versions

PackageAffectedFixed in
LibRaw
Product
all versionsNo fix yet
Details and references

### Summary Uninitialized memory disclosure can be achieved by parsing a truncated RAW picture. ### Severity High - It is possible to exploit the vulnerable pattern in multiple ways and it may lead to complete memory reconstruction of the target allocation - whose size is controllable through TIFF tags - by an attacker with access to the bitmap result or the parsed metadata. ### Proof of Concept 1. Compile LibRaw following the instructions on https://github.com/LibRaw/LibRaw/blob/0.21.2/INSTALL 2. Run the `bin/simple_dcraw` sample binary with the provided file: bin/simple_dcraw [poc.bin](https://github.com/google/security-research/blob/master/pocs/LibRaw/UninitializedMemorypoc.bin) ### Further Analysis LibRaw supports a wide range of RAW picture formats. In order to do so, it employs a format recognition system based on which TIFF tags are found in the file. Once a format is recognized, the `load_raw` function pointer - responsible for extracting the raw image from the input file - is populated with the appropriate handler. Such functions commonly use `LibRaw_buffer_datastream::read` to read from the input buffer, which is semantically equivalent to libc’s [fread](https://linux.die.net/man/3/fread). A number of `load_raw` functions [1] do not check the return value of `LibRaw_buffer_datastream::read` or if the end of input has been reached. This leaves part of the raw image backing buffer uninitialized and allows an attacker to reconstruct portions of heap memory by analyzing the bitmap result. Similarly, some metadata [2] is parsed via the same API and may allow an attacker with access to the parsed metadata to directly read uninitialized heap memory. These functions are affected by the vulnerable pattern: [1] - `LibRaw::nikon_coolscan_load_raw`: https://github.com/LibRaw/LibRaw/blob/0.21.2/src/decoders/decoders_libraw_dcrdefs.cpp#L144 (exploited in the proof of concept below) - `LibRaw::sony_arw2_load_raw`: https://github.com/LibRaw/LibRaw/blob/0.21.2/src/decoders/decoders_dcraw.cpp#L1479 - `LibRaw::rollei_load_raw`: https://github.com/LibRaw/LibRaw/blob/0.21.2/src/decoders/decoders_dcraw.cpp#L990 - `LibRaw::unpack_thumb`: https://github.com/LibRaw/LibRaw/blob/0.21.2/src/decoders/unpack_thumb.cpp#L136 - `LibRaw::nikon_14bit_load_raw`: https://github.com/LibRaw/LibRaw/blob/0.21.2/src/decoders/decoders_libraw.cpp#L203 - `LibRaw::fuji_14bit_load_raw`: https://github.com/LibRaw/LibRaw/blob/0.21.2/src/decoders/decoders_libraw.cpp#L223 - `LibRaw::nikon_load_padded_packed_raw`: https://github.com/LibRaw/LibRaw/blob/0.21.2/src/decoders/decoders_libraw.cpp#L254 - `LibRaw::nikon_load_sraw`: https://github.com/LibRaw/LibRaw/blob/0.21.2/src/decoders/decoders_libraw.cpp#L566 - `LibRaw::pana_data`: https://github.com/LibRaw/LibRaw/blob/0.21.2/src/decoders/decoders_dcraw.cpp#L1102 [2] - `LibRaw::parse_tiff_ifd`: https://github.com/LibRaw/LibRaw/blob/0.21.2/src/metadata/tiff.cpp#L589 - `LibRaw::parseSonyMakernotes`: https://github.com/LibRaw/LibRaw/blob/0.21.2/src/metadata/sony.cpp#L1106 - `LibRaw::PentaxLensInfo`: https://github.com/LibRaw/LibRaw/blob/0.21.2/src/metadata/pentax.cpp#L140 ### Timeline **Date reported**: 09/13/2024 **Date fixed**: 09/18/2024 **Date disclosed**: 10/18/2024

Severity from
GitHub (reviewed advisory)

More Google advisories

All Google
Advisory
Cisco NX OS: Bootloader Script Execution Vulnerability
HighDec 6, 2024
Linux Kernel: TOCTOU in Exec System
MediumDec 2, 2024
ION Group: Account Takeover
CriticalNov 11, 2024
LibRaw: Out of bounds write in LibRaw::pana_data
HighOct 22, 2024
OpenTelemetry: AWS Firehose Receiver Vulnerability
Medium5.3Oct 1, 2024
Eaton: Hardcoded SSH root password in XC-303 firmware
Critical9.1Sep 13, 2024

Critical advisories by email

Wednesdays: the week’s critical and high advisories in the AI and data stack, with the fixed versions. Only in weeks that have some.

Double opt-in. Unsubscribe any time.