Skip to content

fix(issue-732): Add bounds check before native compress - #733

Open
m-rola wants to merge 1 commit into
xerial:mainfrom
m-rola:fix/issue-732-compress-bounds-check
Open

m-rola wants to merge 1 commit into
xerial:mainfrom
m-rola:fix/issue-732-compress-bounds-check

Conversation

@m-rola

@m-rola m-rola commented Sep 15, 2026

Copy link
Copy Markdown

Security Fix

Fixes #732 - Out-of-bounds write vulnerability in Snappy.compress()

Vulnerability Details

Type: Out-of-Bounds Write (CWE-787)
CVSS 3.1: 5.9 (Medium)
Affected versions: 1.1.10.8 and earlier

Root Cause

The compress(ByteBuffer, ByteBuffer) method never validates that the
destination ByteBuffer has sufficient capacity before calling the native
rawCompress function, allowing off-heap out-of-bounds writes.

Fix

Added capacity check before native call:

  • Calculate required capacity using maxCompressedLength()
  • Throw IllegalArgumentException if insufficient space
  • Clear error message shows bytes needed vs available

Testing

Impact

  • Breaking change: No (only throws exception in error case)
  • Performance impact: Negligible (O(1) check)

@github-actions github-actions Bot added the bug label Sep 15, 2026
@beholders-eye

Copy link
Copy Markdown

Are there any plans to merge this?

@tourl

tourl commented Sep 15, 2026

Copy link
Copy Markdown

Hope someone can review this soon...

@marcelstoer

Copy link
Copy Markdown

Fixes #732 - Out-of-bounds write vulnerability in Snappy.compress()

This is very much related to #728.

@beholders-eye

Copy link
Copy Markdown

Thanks @m-rola for stepping up and writing this patch.

@m-rola

m-rola commented Sep 16, 2026

Copy link
Copy Markdown
Author

@xerial can we proceed with merge or I'm missing something?

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

snappy-java through 1.1.10.8 Out-of-Bounds Write via compress

4 participants