Skip to content

Commit 3895461

Browse files
authored
This PR fixes #5329. Previously, the message flags field was able to be modified such that a message that is not sharable according to the share_flags field in H5O_msg_class_t could be treated as sharable. A check has been added to make sure messages that are not sharable can't be modified so that they indicate they can be shared. The bug was first reproduced using the fuzzer and the POC file from #5329. With this change, the heap based buffer overflow no longer occurs.
1 parent 701b46d commit 3895461

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

release_docs/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,12 @@ Added Fortran wrapper h5fdsubfiling_get_file_mapping_f() for the subfiling file
579579

580580
Fixes GitHub issue #5861
581581

582+
### Fixed security issue CVE-2025-2153
583+
584+
The message flags field could be modified such that a message that is not sharable according to the share_flags field in H5O_msg_class_t can be treated as sharable. An assert has been added in H5O__msg_write_real to make sure messages that are not sharable can't be modified to shared. Additionally, the check in H5O__chunk_deserialize that catches unsharable messages being marked as sharable has been improved.
585+
586+
Fixes GitHub issue #5329
587+
582588
### Fixed security issue CVE-2025-6857
583589

584590
An HDF5 file had a corrupted v1 B-tree that would result in a stack overflow when performing a lookup on it. This has been fixed with additional integrity checks.

src/H5Ocache.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,8 +1400,8 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t chunk_size, const uint8_t
14001400
else {
14011401
/* Check for message of unshareable class marked as "shareable"
14021402
*/
1403-
if ((flags & H5O_MSG_FLAG_SHAREABLE) && H5O_msg_class_g[id] &&
1404-
!(H5O_msg_class_g[id]->share_flags & H5O_SHARE_IS_SHARABLE))
1403+
if (((flags & H5O_MSG_FLAG_SHARED) || (flags & H5O_MSG_FLAG_SHAREABLE)) &&
1404+
H5O_msg_class_g[id] && !(H5O_msg_class_g[id]->share_flags & H5O_SHARE_IS_SHARABLE))
14051405
HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL,
14061406
"message of unshareable class flagged as shareable");
14071407

src/H5Omessage.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ H5O__msg_write_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *type, unsigned m
354354
*/
355355
assert(!(mesg_flags & H5O_MSG_FLAG_DONTSHARE));
356356

357+
/* Sanity check to see if the type is not sharable */
358+
assert(type->share_flags & H5O_SHARE_IS_SHARABLE);
359+
357360
/* Remove the old message from the SOHM index */
358361
/* (It would be more efficient to try to share the message first, then
359362
* delete it (avoiding thrashing the index in the case the ref.

0 commit comments

Comments
 (0)