Files
ersatztv/ErsatzTV.Infrastructure/Images/ImageSharpDecoding.cs
T
timothyandClaude Opus 5.5 9eed552876 fix(929): pin System.Security.Cryptography.Pkcs 9.0.21 and stop ImageSharp 3.1.12 decoding TIFF
The Pkcs 9.0.4 that EFCore.BulkExtensions' Oracle/SqlServer providers pull
transitively carries GHSA-846f-f764-76mx (High) and GHSA-2fmv-rv2c-59x7.
It is overridden by a direct reference in ErsatzTV.Infrastructure, the
existing pattern (Microsoft.OpenApi, SQLitePCLRaw). The central transitive
pin the issue suggested was measured and rejected: enabling
CentralPackageTransitivePinningEnabled fails restore with NU1109 in every
project, because Microsoft.Extensions.DependencyModel is exact-pinned [8.0.2]
below the >= 9.0.x EF Core requires.

ImageSharp stays on 3.1.12. Every patched release (3.2.0, 4.1.2, 4.1.3)
ships a build-time Six Labors license check that fails a Release build
without a key (measured: dotnet build -c Release errors 'No Six Labors
license found'), and CI and the image build Release. Of the six 3.1.12
advisories now listed, the two DECODER ones are TIFF; every ImageSharp
decode now goes through a configuration that cannot detect TIFF. The rest
are an encoder, a processor and an accessor ErsatzTV never calls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: f9ce6bc6-5b36-491a-8d72-89c1f70dd3e1
2026-10-30 00:03:25 +01:00

46 lines
2.2 KiB
C#

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Formats.Bmp;
using SixLabors.ImageSharp.Formats.Gif;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.Formats.Pbm;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.Formats.Qoi;
using SixLabors.ImageSharp.Formats.Tga;
using SixLabors.ImageSharp.Formats.Webp;
namespace ErsatzTV.Infrastructure.Images;
/// <summary>
/// The ImageSharp <see cref="Configuration" /> every ImageSharp decode in ErsatzTV goes through.
/// </summary>
/// <remarks>
/// It registers every format <see cref="Configuration.Default" /> registers EXCEPT TIFF, so a TIFF is
/// rejected with <see cref="UnknownImageFormatException" /> before any TIFF decoder code runs.
/// ImageSharp 3.1.12's TIFF decoder carries GHSA-v76p-62qx-wwq2 (heap out-of-bounds write from a tiled
/// fax TIFF) and GHSA-wmxv-xphr-5c9g (non-progressing BigTIFF IFD loop). TIFF is outside the artwork
/// allow-list (<c>ImageContentTypes.Accepted</c>), so what this removes is only a remote-URL or on-disk
/// TIFF graphic. It is a fresh instance rather than a <c>Configuration.Default.Clone()</c> because
/// Clone is shallow: removing a detector from the clone would remove it from Default too.
/// <c>ImageSharpDecodingTests</c> pins the module list against <c>Configuration.Default</c>, so a
/// package bump that adds a format fails a test instead of silently dropping it.
/// Rationale and revisit trigger: <c>security.imagesharp-3x-tiff-decoder-disabled</c>. (ersatztv#929)
/// </remarks>
public static class ImageSharpDecoding
{
public static Configuration Configuration { get; } = new(
new PngConfigurationModule(),
new JpegConfigurationModule(),
new GifConfigurationModule(),
new BmpConfigurationModule(),
new PbmConfigurationModule(),
new TgaConfigurationModule(),
new WebpConfigurationModule(),
new QoiConfigurationModule());
public static DecoderOptions Options() => new() { Configuration = Configuration };
public static DecoderOptions Options(uint maxFrames) =>
new() { Configuration = Configuration, MaxFrames = maxFrames };
}