Skip to content

harden seek table parsing against overflow and oversized frame metadata - #4638

Closed
metsw24-max wants to merge 1 commit into
meta:devfrom
metsw24-max:seekable-table-overflow-hardening
Closed

metsw24-max wants to merge 1 commit into
meta:devfrom
metsw24-max:seekable-table-overflow-hardening

Conversation

@metsw24-max

Copy link
Copy Markdown

This hardens seek table parsing in zstdseek_decompress.c by adding strict bounds checks for untrusted metadata before size arithmetic and memory allocation

Added a hard upper bound check for numFrames from seek table metadata

Added checked arithmetic for table size and frame size computations before multiply/add operations

Added allocation-size overflow guards when allocating seek entries in load path and clone path

These checks reduce memory safety risk by ensuring untrusted metadata cannot trigger wrapped size calculations or undersized allocations.

@meta-cla meta-cla Bot added the CLA Signed label Apr 6, 2026
@metsw24-max

Copy link
Copy Markdown
Author

gentle ping

@Cyan4973 Cyan4973 self-assigned this Nov 8, 2026
@Cyan4973

Cyan4973 commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Thank you for this fix, and sorry for the long wait. The same bound is now in dev through #4717, which rejects numFrames > ZSTD_SEEKABLE_MAXFRAMES before the table size is computed, and adds a regression test. With that bound in place, the other checks here can no longer trigger: the table size stays below 1.5 GiB, and the entry array (including the copy in ZSTD_seekTable_create_fromSeekable()) stays below 4 GiB even with a 32-bit size_t. Closing as superseded by #4717.

@Cyan4973 Cyan4973 closed this Nov 8, 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.

2 participants