Skip to content

fix(fsst): grow decode buffer to prevent out-of-bounds write#7267

Open
Noethix55555 wants to merge 1 commit into
lance-format:mainfrom
Noethix55555:fix/fsst-decode-buffer-oob
Open

fix(fsst): grow decode buffer to prevent out-of-bounds write#7267
Noethix55555 wants to merge 1 commit into
lance-format:mainfrom
Noethix55555:fix/fsst-decode-buffer-oob

Conversation

@Noethix55555

Copy link
Copy Markdown

Summary

fsst::fsst::decompress only required a 3 * input output buffer, but an FSST code byte can decode to an 8-byte symbol and the decode loop writes 8 bytes at a time through raw pointers. On data that compresses better than 3:1, honoring the documented minimum overran the buffer (a heap out-of-bounds write, observed as a segfault).

This sizes the output buffer for the worst case before decoding, then shrinks it to the real length at the end. The change is internal to the decode path and does not change results for callers that already pass a large enough buffer (in-tree callers pass 8 * input).

Closes #7266. Related: #2606.

Test

Added rust/compression/fsst/tests/buffer_bound.rs: it compresses an ~8:1 input and decompresses into the documented 3x buffer. This segfaulted before the change and round-trips correctly after. cargo test -p fsst and cargo clippy -p fsst --tests pass.

decompress only required a 3x output buffer, but an FSST code byte can expand to an 8-byte symbol and the decode loop writes 8 bytes at a time through raw pointers. On data that compresses better than 3:1, honoring the documented minimum overran the buffer (a heap out-of-bounds write, observed as a segfault). Size the output buffer for the worst case before decoding; it is shrunk to the real length afterwards.

Adds a regression test.
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rust/compression/fsst/src/fsst.rs 87.50% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The decompression path still trusts serialized symbol lengths and offsets before entering unsafe decode. Malformed input can write past the allocated buffer or read outside the compressed data.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FSST decompress writes out of bounds when data compresses better than 3:1

2 participants