[Pkg-kde-extras] Bug#1153106: exiv2: JP2 FileTypeBox length < 8 underflows the boxData size (bad_alloc, 0.27 line)
zwf zwf
zwfnetwind at hotmail.com
Thu Nov 5 14:37:54 GMT 2026
Package: exiv2
Version: 0.27.6-1
Severity: normal
Tags: security, upstream
Hello,
exiv2 in bookworm/bullseye dies on a crafted JPEG-2000 file. The 0.28 line is not affected,
but the 0.27 line is, and that is what the stable releases ship.
`Jp2Image::readMetadata()` subtracts the box header size from the attacker-controlled box
length without checking that the length can hold a header (src/jp2image.cpp:212):
boxFileTypeFound = true;
std::vector<byte> boxData(box.length - boxSize); /* 1..7 -> 0xfffffffffffffff9..fffe */
`boxSize` is `sizeof(Jp2BoxHeader)` (8), `box.length` comes straight from the file, and the
earlier bound check plus the `== 0` / `== 1` special cases let 2..7 through. The subtraction
wraps, `std::vector<byte>` asks for ~2^64 bytes, and because the allocation is not caught the
process dies instead of reporting corrupted metadata. The same expression exists in
`printStructure()` (line 479).
Reproduction, 80 bytes: a valid 12-byte JP2 signature box followed by a `ftyp` box whose
length field is 0x00000001.
exiv2 -p a poc-ftyp-len1.jp2
terminate called after throwing an instance of 'std::bad_alloc'
Aborted
With ASan the abort is explicit (`requested allocation size 0xfffffffffffffff9`,
`Jp2Image::readMetadata`). A length of 4 gives the same result.
Suggested fix, attached as a two-line patch (same guard upstream added for the 0.28 line):
enforce(box.length >= sizeof(box), Exiv2::kerCorruptedMetadata);
With it the sample returns through the normal corrupted-metadata path and 40 corpus files
still parse unchanged.
Status: fixed on 0.28 (0.28.7+ carry the guard) and in sid, absent in 0.27.7 and in the whole
`0.27-maintenance` branch, which is frozen at the v0.27.7 merge. Upstream report with the
reproducer and patch: https://github.com/Exiv2/exiv2/issues/9563
Please consider a stable update and a CVE for the 0.27 line.
Thanks,
netwind
zwfnetwind at hotmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-kde-extras/attachments/20261105/3a48304d/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: poc-ftyp-len1.jp2
Type: application/octet-stream
Size: 80 bytes
Desc: poc-ftyp-len1.jp2
URL: <http://alioth-lists.debian.net/pipermail/pkg-kde-extras/attachments/20261105/3a48304d/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-jp2-ftyp-length.patch
Type: application/octet-stream
Size: 1184 bytes
Desc: fix-jp2-ftyp-length.patch
URL: <http://alioth-lists.debian.net/pipermail/pkg-kde-extras/attachments/20261105/3a48304d/attachment-0001.obj>
More information about the pkg-kde-extras
mailing list