CVE Database›Document archive›CVE-2025-57803

CVE-2025-57803

imagemagick: ImageMagick (WriteBMPImage): 32-bit integer overflow when writing BMP scanline stride → heap buffer overflow

Loading…

Severity

Important

Red Hat Product Security

7.5

CVSS 3.1

Review impact separately from score.

Published · August 27, 2025

Updated · August 6, 2026

Description

A flaw was found in ImageMagick. In 32-bit builds, the Bitmap encoder miscalculates the stride value when processing images with very large with. Mathematically, the stride value is calculated as width multiplied by 3 but the theoretical limit of such value is 2^32 for 32-bit integers. So, if this value is exceeded, the encoder uses modulo to convert it down and then takes the smaller value as the actual stride length. This is problematic because the pixel data starts to overlap when being added to the buffer due to the small stride value messing up the rows. This heap buffer overflow allows an attacker to cause a denial of service or, with crafted input, potentially execute arbitrary code.

Statement

This vulnerability is specific to 32-bit ImageMagick builds. Red Hat predominantly only ships 64-bit builds of Kea on its platforms and so the vulnerability affects only customers that install i686 arch rpm packages as these are the only 32-bit builds Red Hat provides. The flaw occurs in the WriteBMPImage function when computing bytes_per_line for 24-bpp BMP images. An integer overflow causes the stride to underflow to a small value, while the writer still emits 3 × width bytes per row. The mismatch immediately produces a large, attacker-controlled heap overwrite.

CVSS score applicability

The CVSS score(s) listed for this vulnerability do not reflect the associated product's status, and are included for informational purposes to better understand the severity of this vulnerability.

Mitigation

No mitigation is specified in collected source.

CVSS / CWE

CVSS 3.1 · 7.5
CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H

CWE-190 · Integer Overflow or Wraparound