CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



CVE-2026-21413
9.80.04%

CVE-2026-21413: Heap-Based Buffer Overflow in LibRaw Lossless JPEG Decoder

Alon Barad
Alon Barad
Software Engineer

Apr 9, 2026·4 min read·3 visits

No Known Exploit

Executive Summary (TL;DR)

A critical heap buffer overflow in LibRaw's CR2 metadata parser allows attackers to execute arbitrary code remotely via maliciously crafted RAW image files.

CVE-2026-21413 is a critical heap-based buffer overflow in the LibRaw library, specifically within the `lossless_jpeg_load_raw` function. Triggered by maliciously crafted RAW files, the vulnerability allows for out-of-bounds memory writes due to improper validation of the `col` index in CR2Slice metadata, resulting in an unauthenticated remote code execution vector.

Vulnerability Overview

LibRaw is an open-source library widely deployed for reading and decoding RAW image files from digital cameras. It serves as a foundational component in numerous downstream image processing applications, including ImageMagick, GIMP, and various operating system media frameworks.

The vulnerability, designated CVE-2026-21413, is a critical heap-based buffer overflow located in the library's lossless_jpeg_load_raw() function. This function handles the decoding of lossless JPEG data embedded within specific RAW formats, predominantly Canon's CR2 format.

The flaw is classified under CWE-129 (Improper Validation of Array Index). It allows an attacker to manipulate the memory space of applications parsing untrusted image files, yielding an unauthenticated remote code execution vector.

Root Cause Analysis

The root cause of CVE-2026-21413 is the absence of adequate boundary checks during the processing of CR2Slice metadata. When LibRaw decodes a CR2 image, it extracts dimension and offset parameters from this metadata to reconstruct the image matrix.

Within the lossless_jpeg_load_raw() execution path, the library utilizes a col (column) index variable derived directly from the parsed CR2Slice data. The code fails to validate whether this col value exceeds the maximum bounds of the dynamically allocated heap buffer reserved for the raw image pixels.

Because the index is trusted implicitly, subsequent memory write operations use the attacker-controlled col value to calculate memory offsets. This enables arbitrary out-of-bounds write primitives on the heap, corrupting adjacent memory structures.

Code Analysis

The vulnerable implementation processes the JPEG slices without verifying the upper limits of the structural parameters. A crafted RAW file can declare abnormally large slice dimensions, directly manipulating the parsing loops.

The fix, introduced in commit 75ed2c12a35b765b3b6ad695cc1f044f19efe644, implements strict bounds checking on the column indices before permitting any memory writes. By evaluating the parsed metadata against the known safe buffer dimensions, the patched code ensures that out-of-bounds indexing is safely aborted.

Any attempt to provide structural dimensions exceeding the allocated pixel array capacity will now trigger an early exit or error state. This structural validation neutralizes the specific metadata manipulation path leveraged by this vulnerability.

Exploitation

Exploitation relies on the target application invoking LibRaw to process an attacker-supplied RAW file. Since no authentication is required, any interface that accepts image uploads or processes images automatically is a viable attack vector.

An attacker constructs a specialized CR2 file where the CR2Slice metadata is strategically altered. By setting the col index to target specific offsets, the attacker forces the application to overwrite adjacent heap metadata or function pointers.

Achieving reliable remote code execution requires precise heap layout manipulation. The attacker must align the target objects in memory so that the out-of-bounds write modifies a critical data structure, redirecting the execution flow to an attacker-controlled payload.

Impact Assessment

The vulnerability carries a maximum CVSS v3.1 score of 9.8, indicating critical severity. A successful exploit results in the complete compromise of the process executing the LibRaw parsing routine.

In a typical web application scenario where user-uploaded images are processed for thumbnail generation or metadata extraction, exploitation yields unauthenticated remote code execution. The attacker inherits the privileges of the processing daemon, often leading to full system compromise or lateral movement within the network.

Alternatively, if reliable code execution fails, the memory corruption predictably leads to application crashes. This introduces a robust denial-of-service vector against automated image processing pipelines.

Remediation

The definitive remediation for CVE-2026-21413 is upgrading the LibRaw library to version 0.22.1 or later. This release incorporates the upstream fix commit 75ed2c12a35b765b3b6ad695cc1f044f19efe644.

System administrators must also identify and update statically linked binaries that package older versions of LibRaw. Downstream software such as ImageMagick and GIMP should be audited and rebuilt against the updated library to ensure comprehensive protection.

If an immediate upgrade is unfeasible, administrators should restrict the uploading and processing of RAW image files, specifically .cr2 files, from untrusted sources. Executing LibRaw-based tasks within isolated sandboxes or containerized environments will limit the blast radius of a successful exploit.

Official Patches

LibRawOfficial patch fixing the out-of-bounds write

Fix Analysis (1)

Technical Appendix

CVSS Score
9.8/ 10
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
EPSS Probability
0.04%
Top 87% most exploited

Affected Systems

LibRaw versions prior to 0.22.1ImageMagick (when compiled with vulnerable LibRaw)GIMP (when utilizing vulnerable LibRaw plugins)Various Linux distributions bundling LibRaw < 0.22.1

Affected Versions Detail

Product
Affected Versions
Fixed Version
LibRaw
LibRaw
< 0.22.10.22.1
AttributeDetail
CWE IDCWE-129
Attack VectorNetwork
CVSS Score9.8
EPSS Score0.00043
Exploit StatusUnexploited / Theoretical
CISA KEVNot Listed

MITRE ATT&CK Mapping

T1190Exploit Public-Facing Application
Initial Access
T1068Exploitation for Privilege Escalation
Privilege Escalation
CWE-129
Improper Validation of Array Index

The product uses untrusted input as an array index, but it does not validate or incorrectly validates the index to ensure it references a valid position within the array.

Vulnerability Timeline

Initial discovery and report by Francesco Benvenuto of Cisco Talos
2026-02-12
LibRaw version 0.22.1 released with patch
2026-04-06
Official public disclosure by Cisco Talos
2026-04-07
NVD and CVE.org records finalized
2026-04-08

References & Sources

  • [1]Cisco Talos Advisory
  • [2]CVE Record
  • [3]LibRaw GitHub Repository
  • [4]LibRaw Download Page
  • [5]GitHub Security Advisory

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.