Skip to content

CVE-2024-28565, CVE-2025-65803 - Fix heap buffer overflow in PSD RLE unpacker - #54

Merged
danoli3 merged 1 commit into
masterfrom
fix/psd-unpackrle-underflow
Aug 16, 2026
Merged

CVE-2024-28565, CVE-2025-65803 - Fix heap buffer overflow in PSD RLE unpacker#54
danoli3 merged 1 commit into
masterfrom
fix/psd-unpackrle-underflow

Conversation

@danoli3

@danoli3 danoli3 commented Aug 14, 2026

Copy link
Copy Markdown
Owner

psdParser::UnpackRLE() clamped the memcpy/memset write count against line_end, but then advanced line/rle_line/srcSize by the raw, unclamped packet length. line could overrun line_end (turning the next iteration's bounds check negative → huge size_t write), and srcSize (unsigned) could underflow when a packet claimed more bytes than were actually left, running rle_line past its real buffer.

Clamps packet length against both the remaining destination and source space before advancing anything, and stops the loop once either buffer is exhausted.

CVE Link
CVE-2024-28565 https://nvd.nist.gov/vuln/detail/CVE-2024-28565
CVE-2025-65803 https://nvd.nist.gov/vuln/detail/CVE-2025-65803

Fixes: CVE-2024-28565
Fixes: CVE-2025-65803

…5-65803)

psdParser::UnpackRLE() clamped the memcpy/memset write count against
line_end, but then unconditionally advanced line/rle_line/srcSize by
the raw, unclamped packet length:

- line advanced past line_end when a packet was clamped, so a later
  iteration's `line_end - line` went negative and got reinterpreted as
  a huge size_t memcpy/memset count - heap buffer overflow WRITE.
- srcSize (unsigned) underflowed to a huge value whenever a packet's
  claimed length exceeded the bytes actually left in the (attacker-
  controlled) rle_line source buffer, letting rle_line run past its
  real allocation on later iterations - heap buffer overflow READ.
- The RLE-compressed packet branch also read one repeat-value byte
  from rle_line with no check that a byte was actually left in
  srcSize.

Clamp packet length against both the remaining destination space and
the remaining source bytes before using it to advance any pointer or
counter, and stop the loop once either buffer is exhausted.

CWE-787 / CWE-125 (Out-of-bounds Write / Read)

Fixes: CVE-2024-28565
Fixes: CVE-2025-65803
@danoli3
danoli3 force-pushed the fix/psd-unpackrle-underflow branch from d459253 to 62971de Compare August 16, 2026 08:28
@danoli3
danoli3 merged commit 8628709 into master Aug 16, 2026
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant