Skip to content
GoogleGHSA-3m8c-vvxw-r44w

LibRaw: Out of bounds write in LibRaw::pana_data

HighPublished Oct 22, 2024

### Summary Memory corruption can be achieved by parsing a RAW picture containing malicious Leaf metadata. ### Severity High - The values written out of bounds are read directly from the input and the size of the overflow is controllable by the length of the input file. If the target binary is compiled with the “-DLIBRAW_NOTHREADS” flag, the overflow manifests in stack memory; without such a flag it manifests in heap memory. ### 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/IntegerWrapAroundPOC.bin) ### Further Analysis LibRaw allows the input file to contain metadata commonly used by different vendors, so it is possible to induce it into recognizing an input file as a Panasonic RAW picture by including a combination of TIFF tags. Among the supported TIFF tags, LibRaw supports metadata in the Leaf format. Such metadata is identified by a 0x8606 TIFF tag and it is handled by the `LibRaw::parse_mos` function. Along with other fields, it is possibl...

GitHub advisory

Affected versions

PackageAffectedFixed in
LibRaw
Product
all versionsNo fix yet
Details and references

### Summary Memory corruption can be achieved by parsing a RAW picture containing malicious Leaf metadata. ### Severity High - The values written out of bounds are read directly from the input and the size of the overflow is controllable by the length of the input file. If the target binary is compiled with the “-DLIBRAW_NOTHREADS” flag, the overflow manifests in stack memory; without such a flag it manifests in heap memory. ### 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/IntegerWrapAroundPOC.bin) ### Further Analysis LibRaw allows the input file to contain metadata commonly used by different vendors, so it is possible to induce it into recognizing an input file as a Panasonic RAW picture by including a combination of TIFF tags. Among the supported TIFF tags, LibRaw supports metadata in the Leaf format. Such metadata is identified by a 0x8606 TIFF tag and it is handled by the `LibRaw::parse_mos` function. Along with other fields, it is possible to control the `load_flags` variable via a `Rows_data` entry: https://github.com/LibRaw/LibRaw/blob/0.21.2/src/metadata/mediumformat.cpp#L514 `load_flags` is an interesting variable: it is used in `LibRaw::pana_data` to limit how many bytes are copied - at most - from the input file, and at which offset into a target buffer, in case it is recognized by LibRaw as a Panasonic RAW picture: https://github.com/LibRaw/LibRaw/blob/0.21.2/src/decoders/decoders_dcraw.cpp#L1102 By specifying `load_flags` greater than 0x4000 it is possible to make the result of the subtraction wraparound and write outside of the destination buffer bounds: `LibRaw::fread` will try to read up to a huge amount of bytes into a buffer `buf` of size 0x4002. Such a buffer is allocated on the stack if the target binary is compiled with the “-DLIBRAW_NOTHREADS” flag, otherwise in the heap. ### 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: Uninitialized memory disclosure via LibRaw_buffer_datastream::read
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.