Skip to content

fix: add Windows Server 2025 32KiB ESE page support#27

Open
takker-hero-se wants to merge 1 commit intosunsetkookaburra:mainfrom
takker-hero-se:fix-ws2025-32k-page-support
Open

fix: add Windows Server 2025 32KiB ESE page support#27
takker-hero-se wants to merge 1 commit intosunsetkookaburra:mainfrom
takker-hero-se:fix-ws2025-32k-page-support

Conversation

@takker-hero-se
Copy link
Copy Markdown

Summary

Windows Server 2025 introduced optional 32KiB ESE database pages for Active Directory (NTDS.dit). The current libesedb vendored source fails to parse these databases due to two issues in the C library. This PR adds two downstream patches to fix them.

Patch 1: fix-ws2025-itag-state.patch (libesedb_page_header.c)

In the 32KiB page format, the available_page_tag field (uint16) has a new layout:

  • Upper 4 bits: ctagReserved (reserved, should be ignored)
  • Lower 12 bits: actual number of page tags

libesedb reads all 16 bits as the tag count, inflating the value and causing out-of-bounds reads / garbage data.

Fix: Mask with & 0x0fff when page_size >= 32768.

Patch 2: zzz-fix-ws2025-btree.patch (libesedb_page_tree.c)

The B-tree leaf page walk (both backward in get_get_first_leaf_page_number and forward in get_number_of_leaf_values) does not validate the IS_LEAF page flag. In 32KiB databases, some pages in the leaf chain may not be actual leaf pages (e.g. zeroed/reallocated pages), causing "not a leaf page" errors or incorrect record counts.

Fix: Check LIBESEDB_PAGE_FLAG_IS_LEAF before processing each page in both walk directions. Added variable declaration at function scope (C89) and proper libcerror_error_set() error handling.

Testing

Tested with real Active Directory databases:

8KiB (WS2019) 32KiB (WS2025)
Tables 14 14
datatable records 7,008 7,029
Users extracted 3,038 3,044
Hashes decrypted 2,491 2,493
link_table records 13,904 485
Membership links 13,248 408
Errors/crashes None None

Notes

  • Both patches follow libyal coding conventions (Allman braces, tab indentation, libcerror_error_set() error handling, C89 variable declarations)
  • The zzz- prefix on the B-tree patch ensures it applies after qol-leaf_pages.patch
  • A corresponding issue/PR will also be submitted to libyal/libesedb

References

Windows Server 2025 introduced 32KiB ESE database pages for Active
Directory (NTDS.dit). This breaks libesedb parsing due to two issues:

1. Page tag count (itagState): In the 32KiB page format, the upper
   4 bits of available_page_tag are reserved (ctagReserved) and only
   the lower 12 bits contain the actual tag count. libesedb reads all
   16 bits, inflating the count and causing garbage offsets.

2. B-tree leaf page walk: Some pages in the leaf page chain may not
   actually be leaf pages (e.g. zeroed pages). The backward and forward
   walk functions do not validate the IS_LEAF flag, leading to errors.

Patches follow libyal coding conventions.

Tested with both 8KiB (WS2019) and 32KiB (WS2025) NTDS.dit databases.
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