CVE-2024-28565, CVE-2025-65803 - Fix heap buffer overflow in PSD RLE unpacker - #54
Merged
Merged
Conversation
…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
force-pushed
the
fix/psd-unpackrle-underflow
branch
from
August 16, 2026 08:28
d459253 to
62971de
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
psdParser::UnpackRLE()clamped thememcpy/memsetwrite count againstline_end, but then advancedline/rle_line/srcSizeby the raw, unclamped packet length.linecould overrunline_end(turning the next iteration's bounds check negative → hugesize_twrite), andsrcSize(unsigned) could underflow when a packet claimed more bytes than were actually left, runningrle_linepast 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.
Fixes: CVE-2024-28565
Fixes: CVE-2025-65803