Skip to content

Guard decoder allocations and size prefixes - #1569

Open
bmehta001 wants to merge 1 commit into
microsoft:mainfrom
bmehta001:bhamehta/fix-decoder-compress-oom
Open

bmehta001 wants to merge 1 commit into
microsoft:mainfrom
bmehta001:bhamehta/fix-decoder-compress-oom

Conversation

@bmehta001

Copy link
Copy Markdown
Contributor

Summary

  • Reject unrepresentable compression sizes and saturated or overflowing zlib allocation bounds before allocation.
  • Use nothrow allocation for the existing Compress API, preserving its signature and reporting allocation failure normally.
  • Read 32-bit and legacy 64-bit size prefixes with memcpy, reject truncated prefixes, and preserve the legacy native-endian format.
  • Add focused allocation-failure, size-boundary, unaligned-input, and legacy-prefix regression tests, including no-exceptions coverage.

This addresses CodeQL alert 121 in PayloadDecoder.cpp. The internal Compress function had no known in-repository callers in the audit; exploitability is not established.

Validation

  • PayloadDecoderTests.*: 15/15 passed on Visual Studio 2026 x64 and WSL/Linux.
  • No-exceptions smoke test passed on Visual Studio 2026 Win32 and WSL/Linux.
  • Full repository misspell workflow and git diff --check passed.

Reject unrepresentable compression bounds and handle allocation failure without exceptions. Decode size prefixes without alignment assumptions and reject truncated prefixes.

Files changed:

- lib/decoder/PayloadDecoder.cpp

- tests/unittests/PayloadDecoderTests.cpp

- tests/no-exceptions/no-exceptions-smoke.cpp

Co-authored-by: Copilot <[email protected]>

Copilot-Session: e5009227-6b49-4803-8153-63d8d94037e3
@bmehta001
bmehta001 requested a review from a team as a code owner November 19, 2026 23:16

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant