Skip to content

Reject index entries shorter than the entry header - #41

Open
inferius wants to merge 1 commit into
ColinFinck:masterfrom
inferius:index-entry-min-length
Open

inferius wants to merge 1 commit into
ColinFinck:masterfrom
inferius:index-entry-min-length

Conversation

@inferius

Copy link
Copy Markdown

NtfsIndexEntry::validate_size checks that the slice holds at least a header and that index_entry_length does not exceed the slice, but it accepts an index_entry_length smaller than INDEX_ENTRY_HEADER_SIZE. On a corrupted volume this has two effects:

  • a length between 1 and 15 truncates the entry slice below the header, so a later access to a header field (the flags at offset 12) goes out of bounds and panics;
  • a length of 0 keeps the entry iterator from advancing, which loops forever.

Both were found by fuzzing a directory listing over a mutated NTFS image (cargo-fuzz / libFuzzer) with the released 0.4.0. The check in master is unchanged from 0.4.0, so this patch adds the lower bound there and returns the existing InvalidIndexEntrySize error.

I have reproduced the two failures on 0.4.0 only. On master I checked that the patch builds and that the existing tests pass, but I have not run the fuzz inputs against it.

🤖 Generated with Claude Code

An index_entry_length below INDEX_ENTRY_HEADER_SIZE passed validate_size.
The entry slice was then truncated below the header, so later header
field accesses went out of bounds, and a length of zero kept the entry
iterator from advancing.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant