Security Advisories (1)
CVE-2026-13708 (2026-07-06)

Imager::File::JPEG versions before 1.003 for Perl leak heap memory when reading a JPEG with repeated APP13 markers in i_readjpeg_wiol. i_readjpeg_wiol walks the marker list libjpeg returns and, for each APP13 marker, allocates a new buffer with *iptc_itext = mymalloc(...) and overwrites the previous pointer without freeing it. Only the final payload is later turned into a Perl scalar and freed, so a JPEG with N such markers leaks the first N-1 payloads on every read. In a long-lived process, such as an upload or thumbnailing service, repeated reads accumulate these leaks and exhaust available memory, a denial of service. The same handler ships bundled in the Imager distribution, where versions before 1.032 are affected and the fix ships in 1.032.

NAME

Imager::File::JPEG - read and write JPEG files

SYNOPSIS

use Imager;

my $img = Imager->new;
$img->read(file=>"foo.jpg")
  or die $img->errstr;

$img->write(file => "foo.jpg")
  or die $img->errstr;

my $version = Imager::File::JPEG->libjpeg_version();
if (Imager::File::JPEG->is_turbojpeg) { ... }
if (Imager::File::JPEG->is_mozjpeg) { ... }

if (Imager::File::JPEG->has_arith_coding) { ... }

DESCRIPTION

Imager's JPEG support is documented in Imager::Files.

Besides providing JPEG support, Imager::File::JPEG has the following methods:

libjpeg_version()
Imager::File::JPEG->libjpeg_version();

Returns version information about the variety of libjpeg Imager::File::JPEG was compiled with. This is determined at build time. This includes:

  • The library type, one of libjpeg, libjpeg-turbo or mozjpeg.

  • version followed by the library version number.

  • api followed by the libjpeg API version.

For libjpeg the API and library versions are always equal.

is_turbojpeg()
Imager::File::JPEG->is_turbojpeg();

Returns true if Imager::File::JPEG was built with libjpeg-turbo. Note that mozjpeg is built on top of libjpeg-turbo so this will return true for mozjpeg.

is_mozjpeg()
Imager::File::JPEG->is_mozjpeg();

Returns true if Imager::File::JPEG was built with mozjpeg. Note that mozjpeg doesn't define its own version numbering, so mozjpeg is detected by defines that only mozjpeg currently defines.

has_arith_coding()

Returns true if the libjpeg variant Imager::File::JPEG was built with has both encoding and decoding support for arithmetic coding.

has_encode_arith_coding()

Returns true if the libjpeg variant Imager::File::JPEG was built with has encoding support for arithmetic coding.

has_decode_arith_coding()

Returns true if the libjpeg variant Imager::File::JPEG was built with has decoding support for arithmetic coding.

AUTHOR

Tony Cook <tonyc@cpan.org>

SEE ALSO

Imager, Imager::Files.