Magick.NET version
Magick.NET-Q8-AnyCPU, 14.12.0
Environment (Operating system, version and so on)
asp.net core 10.0, Ubuntu 24.04.3 LTS (WSL or docker)
Description
Changing the file format for the attached file from JPG to PNG fails on save for that specific file.
The process silently dies when executed in ASP.NET Core on Linux.
An exception is logged when running in a console app and in ASP.NET Core on Windows.
Unhandled exception. ImageMagick.MagickCoderErrorException: Incorrect data in iCCP `' @ error/png.c/MagickPNGError/1306
at ImageMagick.MagickExceptionHelper.Check(IntPtr exception) in /_/src/Magick.NET/Exceptions/MagickExceptionHelper.cs:line 18
at ImageMagick.NativeHelper.CheckException(IntPtr exception) in /_/src/Magick.NET/Native/NativeHelper.cs:line 20
at ImageMagick.MagickImage.NativeMagickImage.WriteStream(IMagickSettings`1 settings, ReadWriteStreamDelegate writer, SeekStreamDelegate seeker, TellStreamDelegate teller, ReadWriteStreamDelegate reader, Void* data) in /_/src/Magick.NET/Generated/Magick.NET.SourceGenerator/ImageMagick.SourceGenerator.NativeInteropGenerator/MagickImage.g.cs:line 6635
at ImageMagick.MagickImage.NativeMagickImage.WriteStream(IMagickSettings`1 settings, ReadWriteStreamDelegate writer, SeekStreamDelegate seeker, TellStreamDelegate teller, ReadWriteStreamDelegate reader) in /_/src/Magick.NET/MagickImage.cs:line 7893
at ImageMagick.MagickImage.Write(Stream stream) in /_/src/Magick.NET/MagickImage.cs:line 7186
at Program.<Main>$(String[] args) in /home/pavel/projects/magiccrash/Program.cs:line 17
This is a security issue for us, as an end user was able to bring down our application simply by re-uploading the file. This should not happen with default settings, even if the image is somehow invalid.
Steps to Reproduce
using (var image = new MagickImage(imagePath))
{
image.Quality = 100;
image.Format = MagickFormat.Png;
MemoryStream stream = new MemoryStream();
image.Write(stream);
}
Please see https://github.com/PashaPash/magiccrash/tree/aspnet for asp.net core example, https://github.com/PashaPash/magiccrash/tree/main for console app.
Images
20260408_1559101234.jpg
Magick.NET version
Magick.NET-Q8-AnyCPU, 14.12.0
Environment (Operating system, version and so on)
asp.net core 10.0, Ubuntu 24.04.3 LTS (WSL or docker)
Description
Changing the file format for the attached file from JPG to PNG fails on save for that specific file.
The process silently dies when executed in ASP.NET Core on Linux.
An exception is logged when running in a console app and in ASP.NET Core on Windows.
This is a security issue for us, as an end user was able to bring down our application simply by re-uploading the file. This should not happen with default settings, even if the image is somehow invalid.
Steps to Reproduce
Please see https://github.com/PashaPash/magiccrash/tree/aspnet for asp.net core example, https://github.com/PashaPash/magiccrash/tree/main for console app.
Images
20260408_1559101234.jpg