Skip to content

Handle undersized data blocks in framed stream decompression#147

Merged
brantburnett merged 2 commits into
mainfrom
GHSA-pggp-6c3x-2xmx
Apr 28, 2026
Merged

Handle undersized data blocks in framed stream decompression#147
brantburnett merged 2 commits into
mainfrom
GHSA-pggp-6c3x-2xmx

Conversation

@brantburnett

Copy link
Copy Markdown
Owner

Motivation

A malformed block in the framed stream format can cause an infinite loop when decompressing the stream. This could be used for a DoS attack if an attacker can control the data.

Modifications

Short-circuit with an InvalidDataException if the block runs out of data before the decompressor has reached the end of the block.

Motivation
----------
A malformed block in the framed stream format can cause an infinite
loop when decompressing the stream. This could be used for a DoS attack
if an attacker can control the data.

Modifications
-------------
Short-circuit with an InvalidDataException if the block runs out of
data before the decompressor has reached the end of the block.

Resolves GHSA-pggp-6c3x-2xmx
Copilot AI review requested due to automatic review settings April 28, 2026 13:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens framed Snappy stream decompression against malformed compressed chunks that can otherwise cause non-terminating behavior (DoS risk) by adding an explicit invalid-data short-circuit and a regression test.

Changes:

  • Add an InvalidDataException guard when a compressed chunk has no remaining bytes but the decompressor still requires input.
  • Add a test case reproducing the malformed framed-input scenario referenced by the security advisory.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
Snappier/Internal/SnappyStreamDecompressor.cs Throws InvalidDataException when a compressed framed chunk is exhausted while the decompressor still needs data.
Snappier.Tests/SnappyStreamTests.cs Adds a regression test ensuring malformed framed input throws rather than looping.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Snappier/Internal/SnappyStreamDecompressor.cs
Comment thread Snappier.Tests/SnappyStreamTests.cs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@brantburnett brantburnett merged commit 96b68fd into main Apr 28, 2026
42 checks passed
@brantburnett brantburnett deleted the GHSA-pggp-6c3x-2xmx branch April 28, 2026 14:14
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.

2 participants