Skip to content

Harden codec and metadata input validation - #3187

Merged
JimBobSquarePants merged 27 commits into
release/4.1.xfrom
fix/security-advisory-triage
Sep 12, 2026
Merged

JimBobSquarePants merged 27 commits into
release/4.1.xfrom
fix/security-advisory-triage

Conversation

@JimBobSquarePants

@JimBobSquarePants JimBobSquarePants commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

This updates codec input validation, metadata handling, floating-point pixel conversion and CCITT encoding on release/4.1.x. The fixes use supplied malformed inputs and targeted regression cases, while retaining the distinction between recoverable data errors and structural errors that prevent decoding from continuing safely.

Changes

  • Validate decoded BMP, GIF and TGA dimensions before creating image buffers.
  • Reject duplicate PNG headers in both decoding and identification. Calculate scanline lengths with wide arithmetic before narrowing to supported buffer sizes, and apply the ancillary integrity policy to invalid compressed ICC and text metadata.
  • Share stream-range validation through extensions on BufferedReadStream. Check BMP ICC offsets and lengths and WebP metadata lengths before allocation, account for WebP padding without overflow, and use the same range checks for JPEG segments. Preserve metadata-skip and recovery behavior, including the mandatory framing checks for WebP ICC chunks before image data.
  • Apply ExifProfile.Parts at the serialization boundary, including lazy profiles and profiles installed immediately before serialization. This is a shared EXIF fix, not a WebP-only filter.
  • Validate ICC tag extents and minimum sizes, calculate CLUT storage from the product of its grid dimensions, and verify that the payload fits before allocating. Reject channel counts unsupported by the four-component conversion machinery without rejecting otherwise valid profiles merely being preserved.
  • Make Numerics.Clamp consistent across scalar, vector and floating-point span overloads: NaN maps to the lower bound and infinities clamp to the endpoints. Use that contract in scaled half-pixel conversions, with matching individual-pixel and bulk behavior. Native IEEE packing remains unchanged; no clamp is added to histogram equalization or luminance indexing, and TensorPrimitives_ is unchanged.
  • Bound BigTIFF directory entry counts by the bytes available. Size CCITT Group 3, Modified Huffman and Group 4 encoder buffers using their encoded-bit bounds, with pixel round-trip coverage for narrow images.
  • Validate EXR decompressed block lengths, including partial final blocks, and interpret signed scanline coordinates relative to the data window. Initialize omitted color channels and clear failed blocks when IgnoreImageData permits recovery. Handle incomplete zlib initialization without dereferencing a null stream.

Regression coverage and validation

Coverage includes supplied PNG, ICC and TIFF payloads, metadata integrity and skip options, floating-point scalar/bulk conversion parity, CCITT pixel round trips, and EXR block recovery. EXR tests distinguish missing or truncated zlib headers from a complete zlib stream that inflates to zero bytes, using deterministic empty-stream bytes across runtimes.

At b11f2eb64, all eight build/test matrix jobs passed in CI run 33940269331: .NET 8 and .NET 10 on Windows, macOS, Ubuntu x64 and Ubuntu ARM64 runners.

Local Release builds also passed, followed by 93 EXR tests on each of .NET 8 and .NET 10 through VSTest, with no failures or skips.

@JimBobSquarePants
JimBobSquarePants merged commit 37bc351 into release/4.1.x Sep 12, 2026
11 checks passed
benolimits pushed a commit to blaizio/blaizio that referenced this pull request Sep 18, 2026
Updated [AngleSharp](https://github.com/AngleSharp/AngleSharp) from
1.8.1 to 1.8.2.

<details>
<summary>Release notes</summary>

_Sourced from [AngleSharp's
releases](https://github.com/AngleSharp/AngleSharp/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/AngleSharp/AngleSharp/commits).
</details>

Updated [bunit](https://github.com/bUnit-dev/bUnit) from 2.10.3 to
2.11.3.

<details>
<summary>Release notes</summary>

_Sourced from [bunit's
releases](https://github.com/bUnit-dev/bUnit/releases)._

## 2.11.3

### Fixed

- `InvokeOnSpacerBeforeVisible` now uses 4 parameters on .NET 11.0.
Reported by [@​vnbaaij](https://github.com/vnbaaij) in #​1915. Fixed by
[@​vnbaaij](https://github.com/vnbaaij) in #​1919.
- A JSInterop timeout elapsing while a result was set could crash the
test host with `InvalidOperationException: Nullable object must have a
value`. Reported by [@​calebcwells](https://github.com/calebcwells) in
[#​1920](bUnit-dev/bUnit#1920). Fixed by
[@​linkdotnet](https://github.com/linkdotnet).

Commits viewable in [compare
view](bUnit-dev/bUnit@v2.10.3...v2.11.3).
</details>

Updated [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest)
from 18.10.0 to 18.10.1.

<details>
<summary>Release notes</summary>

_Sourced from [Microsoft.NET.Test.Sdk's
releases](https://github.com/microsoft/vstest/releases)._

## 18.10.1


## What's Changed
* Isolate code coverage files in published output by @​azat-msft in
microsoft/vstest#16476


**Full Changelog**:
microsoft/vstest@v18.10.0...v18.10.1

Commits viewable in [compare
view](microsoft/vstest@v18.10.0...v18.10.1).
</details>

Updated [SixLabors.ImageSharp](https://github.com/SixLabors/ImageSharp)
from 4.1.1 to 4.1.2.

<details>
<summary>Release notes</summary>

_Sourced from [SixLabors.ImageSharp's
releases](https://github.com/SixLabors/ImageSharp/releases)._

## 4.1.2

## What's Changed
* Harden codec and metadata input validation by @​JimBobSquarePants in
SixLabors/ImageSharp#3187
* Fix TIFF decoding of legacy 8-bit color maps by @​JimBobSquarePants in
SixLabors/ImageSharp#3189


**Full Changelog**:
SixLabors/ImageSharp@v4.1.1...v4.1.2

Commits viewable in [compare
view](SixLabors/ImageSharp@v4.1.1...v4.1.2).
</details>

Updated
[Spectre.Console](https://github.com/spectreconsole/spectre.console)
from 0.57.3-alpha.0.18 to 0.57.3-alpha.0.19.

<details>
<summary>Release notes</summary>

_Sourced from [Spectre.Console's
releases](https://github.com/spectreconsole/spectre.console/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/spectreconsole/spectre.console/commits).
</details>

Updated
[Spectre.Console.Testing](https://github.com/spectreconsole/spectre.console)
from 0.57.3-alpha.0.18 to 0.57.3-alpha.0.19.

<details>
<summary>Release notes</summary>

_Sourced from [Spectre.Console.Testing's
releases](https://github.com/spectreconsole/spectre.console/releases)._

No release notes found for this version range.

Commits viewable in [compare
view](https://github.com/spectreconsole/spectre.console/commits).
</details>

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant