Skip to content

avcodec/jpeg2000dec: fix cdef remapping out-of-bounds write (CVE-2025-9951)#124

Open
dkgkdfg65 wants to merge 1 commit into
ShiftMediaProject:masterfrom
dkgkdfg65:fix-cve-2025-9951
Open

avcodec/jpeg2000dec: fix cdef remapping out-of-bounds write (CVE-2025-9951)#124
dkgkdfg65 wants to merge 1 commit into
ShiftMediaProject:masterfrom
dkgkdfg65:fix-cve-2025-9951

Conversation

@dkgkdfg65
Copy link
Copy Markdown

Fixes #123 (CVE-2025-9951).

The JPEG2000 decoder on the current 7.1.1 base has a heap buffer overflow in write_frame_8: a crafted cdef box can remap a component onto an arbitrary plane, and WRITE_FRAME uses that index without bounds-checking, writing a larger plane's data past a smaller plane's buffer.

This backports the upstream fix:

  • 104d6846c1be avcodec/jpeg2000dec: move cdef default check into get_siz()
  • 01a292c7e365 avcodec/jpeg2000dec: implement cdef remapping during pixel format matching

get_siz() now finalizes cdef early and rejects channel/component combinations that don't match, and the chroma-shift computation uses the remapped index.

Verified with AddressSanitizer on this 7.1.1 build:

…-9951)

Backports the upstream fix onto the 7.1.1 base:
- 104d684  avcodec/jpeg2000dec: move cdef default check into get_siz()
- 01a292c  avcodec/jpeg2000dec: implement cdef remapping during pixel
                format matching

A crafted cdef box could remap a component onto an arbitrary plane, so
WRITE_FRAME indexed planes out of bounds and wrote past a smaller plane's
buffer (heap-buffer-overflow in write_frame_8). get_siz() now finalizes
cdef early and rejects channel combinations that don't match the
component count.

Verified with AddressSanitizer on the 7.1.1 build: the proof-of-concept
file no longer overflows (rejected as invalid) and valid JPEG2000 input
still decodes.
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.

JPEG2000 decoder heap buffer overflow (CVE-2025-9951) not yet backported to 7.1.1

1 participant