Skip to content

Fix CVE-2026-19025 (Reject chunked datasets with mismatched chunk/dspace rank at open time) - #6508

Merged
mattjala merged 11 commits into
HDFGroup:developfrom
mattjala:h5repack_hyperslab_sigfpe
Aug 28, 2026
Merged

Fix CVE-2026-19025 (Reject chunked datasets with mismatched chunk/dspace rank at open time)#6508
mattjala merged 11 commits into
HDFGroup:developfrom
mattjala:h5repack_hyperslab_sigfpe

Conversation

@mattjala

@mattjala mattjala commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

H5D__chunk_construct() only validates that the chunk layout dimensionality matches the dataspace rank at dataset creation time. When an existing dataset is opened, the check wasn't repeated, so a file whose stored chunk rank disagreed with its dataspace rank was accepted.

During chunk I/O the memory-selection rank (from the dataspace) and the file-selection rank (chunk ndims - 1) then differ, which produces a zero stride that causes a divide-by-zero in H5S__hyper_iter_get_seq_list().

H5O__layout_decode() now performs the same dimensionality check on open (the stored chunk rank includes the extra element-size dimension, so it must be exactly one greater than the dataspace rank) and rejects a mismatch with an error.

Added test_chunk_dims_mismatch() as a regression test for this fix within test/dsets.c

Fixes #6491 (CVE-2026-19025)

H5D__chunk_construct() validates that the chunk layout dimensionality
matches the dataspace rank, but that runs only at dataset creation time.
When an existing dataset is opened, H5D__chunk_init() didn't repeat the
check, so a file whose stored chunk rank disagreed with its dataspace rank
was accepted. During chunk I/O the memory-selection rank (from the
dataspace) and the file-selection rank (chunk ndims - 1) then differ, which
produces a zero stride that causes a divide-by-zero in
H5S__hyper_iter_get_seq_list().

H5D__chunk_init() now performs the same dimensionality check on open (the
stored chunk rank includes the extra element-size dimension, so it must be
exactly one greater than the dataspace rank) and rejects a mismatch with an
error.

Added test_chunk_dims_mismatch() as a regression test in test/dsets.c

Fixes HDFGroup#6491
Copilot AI review requested due to automatic review settings July 6, 2026 20:39
@mattjala
mattjala requested a review from lrknox as a code owner July 6, 2026 20:39
@mattjala mattjala added the Component - C Library Core C library issues (usually in the src directory) label Jul 6, 2026
@mattjala mattjala added the Component - Testing Code in test or testpar directories, GitHub workflows label Jul 6, 2026
@mattjala mattjala added the Type - Security Security issues, including library crashers and memory leaks label Jul 6, 2026
@github-project-automation github-project-automation Bot moved this to To be triaged in HDF5 - TRIAGE & TRACK Jul 6, 2026
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Checklist

This PR touches the following areas. Each needs a sign-off
from its listed owners before merging.

✅ All areas have been signed off.

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 pull request hardens chunked-dataset open-time validation to reject malformed files where the stored chunk layout dimensionality disagrees with the dataset dataspace rank, preventing a downstream divide-by-zero during chunk I/O selection iteration (Fixes #6491).

Changes:

  • Add an open-time check in H5D__chunk_init() to ensure stored chunk dimensionality matches dataspace_rank + 1 (datatype-size dimension).
  • Add a regression test (test_chunk_dims_mismatch()) that verifies opening such a malformed chunked dataset fails cleanly.
  • Add a generator and CMake wiring for the malformed reference file, plus a changelog entry documenting the fix.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/H5Dchunk.c Adds open-time validation to reject datasets with mismatched stored chunk ndims vs dataspace rank.
test/dsets.c Adds a regression test that asserts malformed chunk-layout dimensionality is rejected on open.
test/gen_bad_chunk.c Adds a generator program for producing a malformed chunked dataset file used by the regression test.
test/CMakeTests.cmake Registers the new malformed reference file and generator executable in the CMake test configuration.
release_docs/CHANGELOG.md Documents the crash fix and the new open-time validation behavior.

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

Comment thread test/gen_bad_chunk.c Outdated
Comment thread test/gen_bad_chunk.c Outdated
Comment thread test/dsets.c Outdated
mattjala and others added 2 commits July 6, 2026 16:23
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@mattjala
mattjala force-pushed the h5repack_hyperslab_sigfpe branch from 0ccb2cb to daedfba Compare July 6, 2026 21:52
@github-actions
github-actions Bot requested review from glennsong09 and lrknox and removed request for glennsong09 and lrknox July 6, 2026 21:52
Comment thread src/H5Dchunk.c Outdated
Comment thread release_docs/CHANGELOG.md Outdated
Comment thread release_docs/CHANGELOG.md Outdated
Comment thread release_docs/CHANGELOG.md Outdated
Co-authored-by: Larry Knox <lrknox@hdfgroup.org>
@mattjala
mattjala requested a review from hyoklee July 15, 2026 19:35
@mattjala mattjala changed the title Reject chunked datasets with mismatched chunk/dspace rank at open time Fix CVE-2026-19025 (Reject chunked datasets with mismatched chunk/dspace rank at open time) Aug 6, 2026
@mattjala
mattjala marked this pull request as ready for review August 6, 2026 15:17
@mattjala mattjala added this to the HDF5 2.3.0 milestone Aug 6, 2026
hyoklee
hyoklee previously approved these changes Aug 6, 2026

@hyoklee hyoklee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

disagrees -> disagreed
would not be caught -> was not caught

hyoklee
hyoklee previously approved these changes Aug 7, 2026
Comment thread test/gen_bad_chunk.c
@github-actions
github-actions Bot requested review from hyoklee and vchoi-hdfgroup and removed request for glennsong09 and hyoklee August 20, 2026 22:17

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.

Just leaving a note that this file should also (or only, depending on decisions made about CVE testing) exist in the cve_hdf5 repo for testing

@mattjala
mattjala merged commit b7b85e7 into HDFGroup:develop Aug 28, 2026
132 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in HDF5 - TRIAGE & TRACK Aug 28, 2026
@mattjala
mattjala deleted the h5repack_hyperslab_sigfpe branch August 28, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component - C Library Core C library issues (usually in the src directory) Component - Testing Code in test or testpar directories, GitHub workflows Type - Security Security issues, including library crashers and memory leaks

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

h5repack: SIGFPE in H5S__hyper_iter_get_seq_list when repacking dataset

5 participants