A heap out-of-bounds write exists in the Photo CD (PCD) decoder of GraphicsMagick. In DecodeImage() (coders/pcd.c), the Huffman delta loop advances its output pointer with q++ after every decoded delta and never checks it against the end of the heap-allocated luma/chroma plane buffers. The pointer is repositioned only when a sync marker introduces a new plane/row; between sync markers the run length is bounded solely by the input.
A crafted PCD file that positions the pointer near the end of a plane and then supplies a long run of deltas with no intervening sync therefore walks the pointer past the end of the allocation and writes through it. Processing an untrusted PCD file — for example with gm convert or gm identify, or through any application linked against libGraphicsMagick — can corrupt heap memory beyond the buffers.
Summary
AIGraphicsMagick's Photo CD (PCD) decoder can write beyond its heap-allocated image buffers when processing a crafted PCD file. An attacker who can supply an untrusted PCD file may cause heap memory corruption when the file is processed by a GraphicsMagick tool or an application linked against libGraphicsMagick. The input does not specify an authentication requirement or a network attack path.
Who should check
Anyone running GraphicsMagick, including Debian's graphicsmagick package and Fedora's GraphicsMagick package, should check; affected versions were not specified.
What to do
- 1Check the vendor advisory for affected and fixed versions.
- 2Apply the vendor-provided fix when available.