Skip to content

Conversation

@mattjala
Copy link
Contributor

@mattjala mattjala commented Sep 24, 2025

Malformed files can have a zero name-length, which when subtracted lead to an overflow and an out-of-bounds read.

Check that name length is not too small in addition to checking for an overflow directly.


Important

Fixes overflow and out-of-bounds read in H5O__attr_decode() by ensuring name_len is greater than 1 in H5Oattr.c.

  • Security Fix:
    • In H5O__attr_decode() in H5Oattr.c, added a check to ensure name_len is greater than 1 to prevent overflow and out-of-bounds read.
    • This prevents processing of malformed files with zero-length names.

This description was created by Ellipsis for a5a0b30. You can customize this summary. It will automatically update as commits are pushed.

@mattjala mattjala marked this pull request as draft September 24, 2025 22:11
@nbagha1 nbagha1 added this to the Release 2.0.0 milestone Sep 26, 2025
@mattjala mattjala marked this pull request as ready for review September 26, 2025 23:07
bmribler
bmribler previously approved these changes Oct 6, 2025
src/H5Oattr.c Outdated
HGOTO_ERROR(H5E_OHDR, H5E_OVERFLOW, NULL, "ran off end of input buffer while decoding");

/* Verify that retrieved name length (including null byte) is valid */
if (name_len <= 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we find where name_len was decoded?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was decoded earlier in this function - UINT16DECODE(p, name_len); at H5Oattr.c:169. I wanted to put this check next to the other name_len value check.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, I think this check is more appropriate right after the value being decoded.

Copy link
Collaborator

@jhendersonHDF jhendersonHDF left a comment

Choose a reason for hiding this comment

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

Should add a note to the CHANGELOG.md, but otherwise looks good

@github-project-automation github-project-automation bot moved this from To be triaged to In progress in HDF5 - TRIAGE & TRACK Oct 8, 2025
@bmribler bmribler self-requested a review October 9, 2025 17:16
@mattjala mattjala requested a review from jhendersonHDF October 9, 2025 19:06
@lrknox lrknox merged commit 6c86f97 into HDFGroup:develop Oct 9, 2025
90 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in HDF5 - TRIAGE & TRACK Oct 9, 2025
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)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Malformed file leads to buffer overflow during attribute metadata decoding

5 participants