Headline
CVE-2021-37621: Fix infinite loop in Image::printIFDStructure by kevinbackhouse · Pull Request #1778 · Exiv2/exiv2
Exiv2 is a command-line utility and C++ library for reading, writing, deleting, and modifying the metadata of image files. An infinite loop was found in Exiv2 versions v0.27.4 and earlier. The infinite loop is triggered when Exiv2 is used to print the metadata of a crafted image file. An attacker could potentially exploit the vulnerability to cause a denial of service, if they can trick the victim into running Exiv2 on a crafted image file. Note that this bug is only triggered when printing the image ICC profile, which is a less frequently used Exiv2 operation that requires an extra command line option (-p C
). The bug is fixed in version v0.27.5.
Fixes GHSA-m479-7frc-gqqg
The problem is that this loop can be infinite when dirLength is zero. If dirLength > 0 then the loop cannot be infinite because the algorithm uses a set named visits to make sure that the same location is never visited twice. I am not an expert on this format, but it seems unlikely to me that dirLength == 0 is ever valid, so disallowing that is a simple way to fix the bug.
The second commit fixes the bug.
I didn’t like the look of some of the parsing code in this function, so I added a third commit which adds more error checking.
Related news
Gentoo Linux Security Advisory 202312-6 - Multiple vulnerabilities have been discovered in Exiv2, the worst of which can lead to remote code execution. Versions greater than or equal to 0.28.1 are affected.