Windows heap (windows_heap)
The windows_heap pipeline method reduces a cohort of Windows process dumps
(native .msl, for example minidumps imported with memdiver import) to a
small set of brute-force candidates. It parses the process heaps of every
dump, pairs heap blocks across the dumps by what they are rather than by where
they are, and builds a reduced heap consensus matrix from those pairs.
Every block of one reference dump then gets one verdict, and the kept blocks go
to candidates.json for brute force.
Windows, Go, and Scudo use the same block consensus engine.
1. Concept
Every ssh.exe session is a separately started process. ASLR moves the heap
bases, and the allocator puts the same logical object (say, the 64-byte
ChaCha20-Poly1305 key) into a different subsegment and a different slot in
every run. A positional consensus compares the dumps at the same offset (or
the same virtual address, or the same module-relative address), so on private
heap memory it compares unrelated bytes. A standalone virtual-address or
module-relative consensus (memdiver consensus --align-by …) therefore drops
private memory and warns alignment.private_memory_not_comparable. The
pipeline’s positional consensus over .msl dumps intersects regions by region
key, and on the Win10 x64 AES set it left the heap segment holding the keys out
of its slab. It warns alignment.private_memory_not_comparable there too,
unless no heap was dropped (heaps of equal size share a region key and are then
compared at the same page offset, which still compares unrelated bytes). On the real Windows ssh.exe sets
the positional pipeline kept 5.2 MB (Win10 x64) and 14.4 MB (Win11 ARM64
ChaCha) of candidates, and those candidates held none of the session keys (see
Measured results).
The windows_heap method parses first and compares second. It walks the heaps
of each dump with MemDiver’s NT heap and segment heap parsers and turns every
busy block into a record with a block signature: heap kind, heap role,
allocator component, size class, and user length, for example
win:nt_heap:heap:lfh:b80:s72. Blocks with the same signature are paired
across the dumps. Where a signature occurs several times per dump, blocks are
paired by their pointer-masked content instead. The paired blocks are laid end
to end into an N × L byte matrix (N dumps, L paired bytes) with a per-byte
variance. A block whose content occurs in no other dump is a per-run value,
which is what a session key is. Such blocks are kept even when they could not
be paired.
The key block moves between runs; the block signature finds it again, while a positional comparison does not.
2. Windows heap primer
This section covers only the structures MemDiver reads. The full parser documentation, including the verification tables, is in the user guide: Windows segment heap and Windows NT heap.
Process heaps
A Windows process has one default process heap (PEB.ProcessHeap) and any
number of further heaps listed in PEB.ProcessHeaps. Each heap is one of two
kinds:
the NT heap (
_HEAP, the classic heap). The Win10 22H2 x64ssh.exeprocess heap is an NT heap with an active low-fragmentation heap (LFH).the segment heap (
_SEGMENT_HEAP). The Win11 25H2 ARM64ssh.exeprocess heap is a segment heap.
MemDiver finds heaps without symbols. One numpy pass over all captured pages
reads the u32 at page offset +0x10 and collects 0xFFEEFFEE (NT heap; the
page must also be 64 KiB aligned and hold 0xEEFFEEFF at +0x98) and
0xDDEEDDEE (segment heap). When the .msl stores a thread context, the PEB
is reached through the TEB (gs_base on x64, x18 on ARM64). The PEB only adds
candidates and names roles; it never removes a heap that validates on its own.
A candidate is accepted only by its self-pointers (for example
Segment.Heap == self and Segment.BaseAddress == self for an NT heap), never
by a build number. On the real Win10 dumps the read-only shared heap is refused
this way, with the failed checks named in the layout diagnostics.
Whichever kind wins detection, its parser also composes the other kind’s
blocks into the same layout. A secondary block that overlaps a primary one is
dropped. So both kinds are judged in one run: the Win11 ARM64 references are
segment_heap layouts with heap_kinds ["nt_heap", "segment_heap"], and the
Win10 x64 references are nt_heap layouts with heap_kinds ["nt_heap"].
The NT heap: segments and backend entries
The NT heap structures MemDiver walks, with the Win10 1903+ (nt_1903plus) offsets.
An NT heap starts with _HEAP, which is also its first segment. Further
segments hang off the SegmentList ring at +0x120. Each segment holds a run
of backend entries from FirstEntry (+0x40) to LastValidEntry
(+0x48); ranges listed in UCRSegmentList (+0x60) are uncommitted and are
skipped. Every entry starts with a 16-byte _HEAP_ENTRY:
bytes
[0, 8)belong to the previous block (its last private data);bytes
[8, 16)are the header proper and are XOR-encoded whenEncodeFlagMask(+0x7C) has bit0x100000set. The mask is_HEAP.Encodingbytes[8, 16), at_HEAP+0x88, stored in the heap itself. There is nothing to recover: MemDiver reads the mask and XORs.
Bit-level decode of a backend _HEAP_ENTRY (heap Encoding mask) and of an LFH block header (RtlpLFHKey), with invented but mutually consistent values.
The decoded header (ntheap_backend.decode_entry) is, as bit fields of the
little-endian u64 p = u64(entry[8:16]) XOR mask:
Bits |
Field |
Use |
|---|---|---|
|
|
entry size in 16-byte units, including the header; the next entry is at |
|
|
bit |
|
|
checksum: |
|
|
cross-checked against the previous entry (mismatches are counted) |
|
|
recorded |
|
|
kept raw in |
The walk stops by name on a failed checksum, a zero size, an uncaptured entry,
an entry that overruns its committed range, or an entry budget of 2^20 per
segment. It never resyncs. A backend entry becomes the chunk
[e + 8, e + 8 + Size·16) with header_len = 8, user data from e + 0x10,
and user_len = Size·16 − 8 (cut at the end of the committed range). That length is an upper bound: the backend
UnusedBytes is kept raw and not subtracted. Blocks the heap allocated with
VirtualAlloc (VirtualAllocdBlocks, +0x110) are parsed with a 0x40-byte
header; they are verified only on synthetic fixtures.
The NT heap LFH front end
When FrontEndHeapType (+0x1A2 on 1903 and later, +0x17A on 1507) is 2,
FrontEndHeap (+0x198 / +0x170) points at an _LFH_HEAP. MemDiver picks
the offset profile by self-check (the _LFH_HEAP.Heap field at +0x18 must
point back at the heap), never by version string. The LFH serves small
allocations from subsegments:
_LFH_HEAP.SubSegmentZones(+0x08) is a list of_LFH_BLOCK_ZONEs. Each zone’sNextIndex(+0x10) counts the used_HEAP_SUBSEGMENTrecords (0x40 bytes each) that follow the zone header. The array starts at+0x20or+0x18; MemDiver keeps the start whose records point back.A
_HEAP_SUBSEGMENTgivesUserBlocks(+0x08),BlockSize(+0x24, in 16-byte units: the stride, header included) andBlockCount(+0x28). Each LFH bucket (size class) has its own subsegments; the bucket in a signature is the stride in bytes (b80= stride 0x50).UserBlocksis a_HEAP_USERDATA_HEADER. It must point back at its subsegment (+0x00) and carry the signature0xF0E0D0C0(+0x14), andBlockSize,BlockCountandEncodedOffsetsmust be readable and non-zero. Records that fail these checks are refused and counted (5 stale zone records in total over the four Win10 x64 dumps). UserBlocks holdsEncodedOffsets(+0x18, see below) and theBusyBitmap(SizeOfBitMapat+0x20, buffer pointer at+0x28, bits from+0x30). A bitmap whoseSizeOfBitMapdiffers fromBlockCountis not used: the subsegment is still placed, but its blocks’ state isUNKNOWN.UserBlocks itself lives inside one busy backend entry (its host, at
UserBlocks − 0x10). The host gives the span the blocks must fit in.Block
iis the_HEAP_ENTRYate = UserBlocks + FirstAllocationOffset + i·stride. Its state is bitiofBusyBitmap. Each block header holds an encodedSubSegmentCode(u32 ate + 8) and a plainUnusedBytesbyte ate + 0x0F:0x80for a free block,0x80 | nfor a busy block withnunused bytes. A disagreement between the bitmap andUnusedBytesleaves that block’s stateUNKNOWN(state_conflicts).
MemDiver cuts LFH blocks exactly like backend entries: chunk
[e + 8, e + 8 + stride), user data from e + 0x10, user_len = stride − 8
(again an upper bound), bin nt_lfh_<stride> (for example nt_lfh_80). For a
busy block with n ≥ 8, extra.requested_size = stride − n records the size
the program asked for. The bytes before the first block become an
nt_lfh_userdata_header metadata chunk, the bytes after the last one an
nt_lfh_tail, and the host backend entry is replaced by these chunks.
Recovering RtlpLFHKey
FirstAllocationOffset (FAO) is not stored in the clear. ntdll stores
EncodedOffsets in UserBlocks as
EncodedOffsets = ((stride << 16) | FAO) ^ (u32)UserBlocks ^ (u32)_LFH_HEAP ^ RtlpLFHKey
RtlpLFHKey is a per-process 32-bit secret in ntdll’s data. MemDiver
recovers it from the dump by known plaintext: no symbols, no brute force
over 2^32 keys, and no need to know where ntdll keeps it
(heap/allocators/ntheap_lfh.py, key_candidates / _place_blocks).
RtlpLFHKey recovery by known plaintext; the example numbers were produced by the parser’s own functions on invented inputs.
Step by step:
Plain check first. If, for every subsegment, the high half of
EncodedOffsetsalready equals the stride and the low half is a legal FAO, the offsets are stored in the clear (Windows 8 form,offsets_mode = plain) and no key is needed.Strip the known terms. For every subsegment
s,x_s = EncodedOffsets_s ^ UserBlocks_s ^ _LFH_HEAP(all truncated to 32 bits) leaves((stride_s << 16) | FAO_s) ^ K.High 16 bits. The stride is known plaintext (
BlockSize · 16from the_HEAP_SUBSEGMENT), sohi16(x_s) ^ stride_sisK_hi. It must be the same value for every subsegment, or the key is not derived (“BlockStride known plaintext gives inconsistent key halves”).Low 16 bits. The FAO is not known, but it has few legal values (
offset_candidates): 16-aligned; at leastalign16(0x30 + bitmap bytes), where the bitmap takes whole u64 words; the blocks must fit the host entry’s span; and the tail after the last block must be shorter than two strides (plus a page when the subsegment has a guard page). Without a usable host entry the candidates are the 16-aligned values in[lowest, lowest + stride). Each subsegment yields the set{lo16(x_s) ^ f : f legal};K_lomust lie in the intersection over all subsegments.Decide. Exactly one surviving
(K_hi << 16) | K_lois the key. If several survive, each candidate places every subsegment and counts the block headers whoseSubSegmentCodematchesRtlpLFHKey ^ (u32)_HEAP ^ (u32)(e >> 4) ^ (((e − UserBlocks) >> 4) << 16)(lfh_header_code); the unique best with at least one match wins. The_HEAP.Encodingmask is not applied to this word. If no candidate survives, or the headers do not pick one, the key is not derived and the walk recordsRtlpLFHKey not derived: <why>.Use it. With a key,
FAO_s = lo16(x_s ^ K)places every subsegment (offsets_mode = key), every block header is checked (header_ok), and the aligned copies of the key in ntdll’s writable data are counted (key_in_ntdll). That count is confirmation only; the recovery never reads ntdll. The key is never reported.
On the four Win10 22H2 x64 ssh.exe dumps all 178 subsegments were placed in
key mode, all 11,719 block headers matched, BusyBitmap and UnusedBytes
agreed on every block (9,809 busy, 1,910 free), and the key occurred exactly
once in ntdll’s writable data in every process (user guide,
Evidence on Windows 10).
When an LFH subsegment stays opaque: nt_lfh_subsegment_opaque
Without a key (offsets_mode = per-subsegment) each subsegment is placed on
its own (_place_without_key):
Key-free fallback. If exactly one legal FAO makes every block’s
UnusedBytesagree with itsBusyBitmapbit, that FAO is used. This needs a readable bitmap whoseSizeOfBitMapequalsBlockCount.Otherwise, if there is exactly one legal FAO at all, it is used.
Otherwise the subsegment is not placed. Its host entry becomes a single metadata chunk with bin
nt_lfh_subsegment_opaque, componentlfhanduser_len = 0, and thewindows_heapmethod reports it as an opaque area with reasonlfh_subsegment_undecoded.
So nt_lfh_subsegment_opaque fires only when the key is not derived and
neither the key-free fallback nor a single legal FAO places the subsegment.
It is never paired, kept or dropped; its bytes are simply not judged. Before
the LFH decoder existed, the whole subsegment was such an area: an earlier
heap at lookup on the Win10 x64 ChaCha dumps reported the key inside a
4,104-byte nt_lfh_subsegment_opaque region tagged allocator metadata. With
the decoder, the same keys are busy b80 LFH blocks (see
Where the keys were). After LFH decoding, all real
Windows sets in this page have 0 opaque areas.
If the front end itself is refused (FrontEndHeapType is 2 but _LFH_HEAP.Heap
does not point back, or both profiles qualify), no subsegments are walked. The
UserBlocks then stay inside their busy host backend entries and are judged as
large backend blocks.
The segment heap (Win11 ARM64)
The segment heap is parsed to the same depth: _SEGMENT_HEAP (0xDDEEDDEE
at +0x10), accepted by its self-pointers under exactly one layout profile
(seg_26100plus, verified on ARM64 build 26200; seg_19h1_22h2 from type
listings only). Two segment contexts chain page segments (4 KiB units /
1 MiB, and 64 KiB units / 16 MiB); a page-range descriptor names each range’s
kind: VS subsegment, LFH subsegment, backend block, or free range. The parts
windows_heap judges are:
LFH blocks. Headerless: block
iis atsub + FirstBlockOffset + i·BlockSizeand user data starts at the block start.BlockOffsetsis encoded with the low 32 bits of the process’sLfhKeyandsub >> 12. MemDiver recovers that key by known plaintext as well: for the subsegment with the most blocks, every 16-aligned(BlockSize, FirstBlockOffset)that packs the range tightly gives a candidate key, and only a key under which every subsegment packs tightly survives; it must be unique. Busy/free comes from the subsegment bitmap (layout chosen byBlockCount − busy == FreeCount). A busy block’s user length is the block size minus the unused bytes recorded in its tail, so in a signatures<len>is the requested size. The bucket is the block size (b64= 64-byte blocks).VS blocks. 16-byte chunk headers XOR-encoded with the chunk address and the process’s
HeapKey.HeapKeyis recovered from the page segments (Signature = segment ^ &SegContext ^ HeapKeymust give one value for all segments; the plain or legacy variant is chosen by which one decodes a VS chunk header). User length = chunk size − header − unused bytes.Backend blocks (
seg_backend, user length = used length of the range) and large allocations (implemented, unverified on real data).Heap role.
process(listed inPEB.ProcessHeaps),metadata(global flags0x2400000; every byte is allocator metadata),unlisted, orunknownwhen there is no PEB.
Refusals change what reaches the method: without a unique LfhKey, LFH ranges
become opaque seg_lfh_range chunks (opaque_range); without a HeapKey,
VS ranges become opaque, but backend ranges stay ordinary busy seg_backend
blocks (confidence 0.3) and are still judged. An unwalkable VS tail becomes an
opaque seg_vs_unwalked chunk.
Busy, free and user data
Only busy (IN_USE) blocks with user bytes become blocks of the method.
Free blocks (LFH slots whose bitmap bit is clear, free backend entries, freed VS
chunks, free ranges) are counted in the scan (free_blocks) and are out of
scope: a key left in a freed slot is never a windows_heap candidate. Heap
metadata (heap headers, segment headers, UserBlocks headers, LFH tails, the
segment heap’s metadata heap) is never a block. A block is read through the
.msl VAS map; if any of its user bytes is not captured it is counted
(uncaptured_blocks) and left out, so its signature becomes missing from that
dump rather than being paired on partial bytes.
3. From blocks to the matrix
The method runs build_winheap_consensus (engine/winheap_block_consensus.py)
and then the shared engine (engine/heap_block_consensus.py, described in
Block consensus engine).
Blocks and opaque areas
extract_blocks calls analyze_heap(source, allocator) with the parser hint
(auto, segment_heap, nt_heap) and walks the layout’s chunks in order
(blocks_from_layout):
Step |
Condition |
Outcome |
|---|---|---|
0 |
the layout’s allocator is not a Windows heap kind |
no blocks; |
1 |
the chunk’s own |
skipped |
2 |
bin |
opaque area, reason |
3 |
|
opaque area, reason |
4 |
state |
opaque area, reason |
5 |
metadata, or component not |
skipped |
6 |
state not |
counted as a free block |
7 |
a user byte not captured |
counted as an uncaptured block |
8 |
otherwise |
a block: signature, user VA, user bytes |
Opaque areas are found in every dump’s scan and never judged; the
winheap.opaque warning and the opaque summary report the reference’s.
The block signature
win:<heap kind>:<heap role>:<component>:<bucket>:s<user length>
Field |
Values |
Source |
|---|---|---|
heap kind |
|
the chunk’s |
heap role |
segment heap: |
|
component |
|
|
bucket |
|
|
user length |
|
the parser’s |
Real examples:
win:nt_heap:heap:lfh:b80:s72: an NT heap LFH block of stride 0x50; 72 user bytes are the slot minus its 8 header bytes. The Win10 x64 ChaCha keys (requested size 64) sit in such blocks.win:nt_heap:heap:lfh:b48:s40andwin:nt_heap:heap:lfh:b272:s264: the Win10 x64 AES-256 key (requested 32) and its cipher context (requested 264).win:nt_heap:heap:backend:backend:s200: an NT backend entry of 208 bytes.win:segment_heap:process:lfh:b64:s64and…:lfh:b32:s32: segment heap LFH blocks of the process heap whose requested size fills the block (the Win11 ARM64 ChaCha and AES keys).win:segment_heap:process:vs:vs:s264: a 264-byte VS allocation.
Two blocks with the same signature have the same user length, so every paired
group is a rectangle of N × length bytes. Because the NT s<len> is an upper
bound, NT blocks of different requested sizes in one bucket share a signature
(for example every busy b80 block is s72); content pairing then has to
separate them.
Pairing: signature first, then content
Let count_d(sig) be how often a signature occurs in dump d
(align_blocks):
signature-unique: exactly once in every dump. The N blocks are paired directly and become one row keyed by the bare signature.
ambiguous: at least once in every dump and more than once in some dump. These go to content pairing.
missing: absent from at least one dump. Never compared; the reference’s blocks with such a signature get the verdict
missing(not judged).
Content pairing (content_align) splits each ambiguous signature by the
blocks’ pointer-masked bytes. Each dump’s mask is built from its own
mapped address ranges (every VAS-map entry, readable or not; the stored
regions if there is no VAS map). Every 8-byte-aligned little-endian u64 word
at offset 0, 8, 16, … is treated as a pointer and zeroed when it is at least
0x10000 and lies inside one of those ranges (end inclusive, so a
one-past-end pointer counts). Trailing bytes that do not fill a word are kept.
The mask only decides correspondence: the rows keep the raw bytes, so a pointer
word still shows up as variance. Not recognised: encoded pointers
(EncodePointer, heap-encoded headers), 32-bit or unaligned pointers. An
integer that happens to fall in a mapped range is masked too.
For each masked content k of an ambiguous signature:
|
Result |
|---|---|
every dump, exactly once each |
paired: row |
every dump, more than once somewhere |
counted ( |
2 … N−1 dumps |
counted ( |
exactly one dump |
dynamic: a per-run value |
The dynamic blocks of a signature become one more row <sig>#dynamic
(class dynamic_residue) only when N ≥ 2 and every dump has exactly one
dynamic block for it. Otherwise each dynamic block stays unpaired and is
recorded, by user VA and size, as a dynamic candidate of its dump.
The N × L slab and its variance
The rows are laid end to end into one synthetic slab
(build_object_vector): first the signature-unique rows in sorted signature
order, then, per ambiguous signature in sorted order, its #content rows (in
masked-content order) and its #dynamic row. Conceptually this is a matrix
with N rows (dumps) and L columns, L = the sum of all row lengths
(bytes_compared). For each row, the N × length block is stacked as float32
and its population variance per column (numpy.var(axis=0)) is stored at
the row’s slab offset; the row also records its slab offset, length, each
dump’s user VA, its class, its masked word offsets and its mean variance. The
slab’s reference bytes are dump 0’s (the first dump given), not necessarily the
chosen reference; this does not affect the output, because the regions are
re-read from the reference.
Signature-unique rows come first so that their slab offsets do not depend on whether content alignment ran. The producer always runs content alignment.
When nothing was compared or more than 10 % of the block bytes were not, a
coverage warning is logged, for example on the Win10 x64 ChaCha set:
compared 399896 bytes per dump; 2195024 chunk bytes (57.8% of the input) were not compared: 2186272 bytes in 56 ambiguous signature(s) …; 8752 bytes in 5 missing signature(s).
Verdicts
Every block of the reference dump gets exactly one verdict
(classify_winheap_blocks → classify_blocks), first match wins:
# |
Condition |
Verdict |
Kept |
|---|---|---|---|
1 |
no user bytes |
|
no |
2 |
in a signature-unique row with mean variance > 0 |
|
yes |
3 |
in a signature-unique row with mean variance 0 |
|
no |
4 |
in a |
|
yes |
5 |
in a |
|
no |
6 |
a dynamic candidate (content in no other dump) |
|
yes |
7 |
signature missing from some dump |
|
not judged |
8 |
ambiguous, unpaired, not dynamic |
|
no |
The variance enters only through rule 2 and 3 (> 0 versus exactly 0).
There is no variance floor and no byte classification in this method; a
#content row is dropped even when its pointer words vary. The verdicts form a
partition: their block and byte counts add up to the reference’s blocks. A
signature that is missing from any dump removes those blocks from every
reference’s judgement, and the reference is itself one of the N dumps.
Where the keys were
On all ten real ssh.exe dumps (4 Win10 x64 ChaCha, 3 Win11 ARM64 ChaCha,
3 Win11 ARM64 AES), measured by joining every verified brute-force hit with the
candidate region that contains it, the session keys sat at offset 0 of a busy
LFH block and came out as dynamic_candidate, never through a variance
row:
Set |
Signature of the key block |
Verdict |
Key offset |
|---|---|---|---|
Win10 x64 ChaCha (every reference of 4) |
|
|
0 |
Win11 ARM64 ChaCha (every reference of 3) |
|
|
0 |
Win11 ARM64 AES (every reference of 3) |
|
|
0 |
Both directions’ keys (client-to-server and server-to-client) are in the same
signature group. That group is ambiguous (each dump has many 72-, 64- or
32-byte LFH blocks). After pointer masking, the key’s content occurs in no other
dump; because each dump holds more than one such per-run block, no #dynamic
row is formed, and the key is kept as an unpaired dynamic candidate. Its
candidates.json region therefore has no row and no mean_variance. On the
ARM64 AES set the memory oracle also proved a word-swapped copy of each key in
the AES key schedule, a win:segment_heap:process:vs:vs:s264 block, again as a
dynamic_candidate.
On the Win10 x64 AES set (OpenSSH for Windows 9.5p1, aes256-ctr +
hmac-sha2-256, 4 ssh.exe minidumps captured 2026-11-29), every proven
artefact is busy user data of the NT process heap (nt_1903plus, LFH active),
at offset 0 of its block:
Artefact |
Heap block |
Signature |
|---|---|---|
AES-256 encryption key |
LFH, stride 48, requested 32 |
|
AES key schedule (its first 32 bytes are a second raw copy of the key) |
LFH, stride 272, requested 264 |
|
raw HMAC-SHA2-256 key |
LFH, stride 48, requested 32 |
|
HMAC inner/outer midstates, the |
128-byte backend chunks (session 4: one 144-byte backend and one LFH 128 chunk) |
|
In the first windows_heap run on that set (reference = session 1), brute force
with the derived-state oracle hit both encryption keys twice each, once in a
b48:s40 block and once in a b272:s264 block, all four as
dynamic_candidate. A second run with the oracle’s hmac-sha256 chain proved both raw
MAC keys in b48:s40 blocks.
Where the session keys sat: always at user offset 0 of a busy LFH block, with the NT heap’s 8 header bytes inside the chunk and its unused tail inside s<len>.
Back to the reference dump, and brute force
The kept blocks, sorted by VA, are translated into the reference’s flat
"vas" view (translate_regions): offset = va_to_vas_offset(va); the last
byte must map to offset + length − 1 (the block is contiguous in the view);
and the bytes read there must equal the block bytes the consensus judged.
Blocks that fail are skipped and counted (not_captured, not_contiguous,
bytes_mismatch; warning winheap.candidates_skipped). A reference with a
short captured run is refused (winheap.reference_truncated).
The producer writes <output_dir>/candidates.json:
summary:
source = "search-reduce:winheap",method = "windows_heap",version,consensus(method = "winheap_block_signature",aligned_rows,ambiguous_signatures,missing_signatures,empty_signatures),N,dumps,reference_dump,reference_index,cohort,region_scope(the reference’s heap scan:kind = "heap_parser",allocator,windows_heap,heap_kinds,blocks,block_bytes,by_component,free_blocks,uncaptured_blocks,opaque,truncated,diagnostics),opaque,funnel({verdict: {"chunks", "bytes"}}: the block count and bytes per verdict, zeros included),not_judged,skipped,totals(regions,bytes,key_sizes,stride = 1,windows),diagnostics;regions: one per kept block withoffset,length,va,signature,selected_as(the verdict), androw/mean_varianceonly for a paired block.
totals.windows is the number of key-sized windows brute force will test at
stride 1 (per region and key size, length − k + 1, 0 when the region is
shorter than the key). The per-signature dynamic-candidate lists are not written
to candidates.json; only the reference’s funnel.dynamic_candidate count is.
Brute force then tests every window with an oracle against the reference dump.
The memory-proof format oracles (packet-residue for SSH ChaCha20-Poly1305,
derived-state for AES) need no traffic capture: the sweep gives them the
reference dump’s memory once per run and screens each batch before the costly
memory search.
4. Worked example
Three dumps of an NT-heap process (numbers invented, small on purpose). Each dump holds these busy blocks, in different places:
Block |
Signature |
dump 0 (reference) |
dump 1 |
dump 2 |
|---|---|---|---|---|
a |
|
1 (same bytes everywhere) |
1 |
1 |
b |
|
1 (a counter that differs) |
1 |
1 |
c48 |
|
1 |
1 |
1 |
d |
|
1 |
1 |
1 |
c80 |
|
1 |
1 |
1 |
p |
|
1 |
1 |
1 |
K |
|
2 (c2s, s2c) |
2 |
2 |
x |
|
1 |
1 |
0 |
m |
|
1 |
1 |
0 |
(… = win:nt_heap:heap.)
Signatures. s1016 and s232 occur once in every dump: signature-unique.
b48:s40 (2 per dump) and b80:s72 (5, 5, 4) occur in every dump, more than
once: ambiguous. b32:s24 is absent from dump 2: missing.
Content. Within b48:s40, c48 has the same masked bytes in all three
dumps (a #content row); d is different in every dump and each dump has
exactly one such block, so the three d blocks form the #dynamic row.
Within b80:s72, c80 pairs as #content; p differs only in its pointer
word, which the mask zeroes, so it pairs as #content too (masked word offset
0). x appears in two dumps (partial), and each K appears in one dump only
(dynamic), but every dump has two of them, so they are not paired.
Matrix. Six rows, N = 3, L = 1016 + 232 + 40 + 40 + 72 + 72 = 1,472 byte
columns. Variance: 0 over s1016, > 0 over s232, 0 over the b48 content
row, > 0 over the #dynamic row, > 0 only within the first 8 columns of
the p row (the raw pointer), and 0 over the c80 row. (p comes before c80
because the content rows are sorted by their masked bytes, and p’s first word
is masked to zero.) Of the 5,040 block bytes of
the three dumps, 3 × 1,472 = 4,416 were compared and 624 were not (576 in
ambiguous blocks, 48 in the missing signature).
The worked example: three dumps’ blocks, the reduced 3 × 1,472 slab with its variance, and the verdicts for dump 0.
Verdicts for dump 0 (10 blocks, 1,712 bytes).
Verdict |
Blocks |
Bytes |
Kept |
|---|---|---|---|
|
1 |
232 |
yes |
|
1 |
40 |
yes |
|
2 |
144 |
yes |
|
1 |
1,016 |
no |
|
3 |
184 |
no |
|
1 |
72 |
no |
|
1 |
24 |
not judged |
candidates.json gets 4 regions, 416 bytes. With 64-byte keys brute force
tests 232 − 63 + 0 + 2 × (72 − 63) = 187 windows (the 40-byte block is shorter
than the key and contributes none), and the two keys are among them, at offset
0 of their 72-byte regions.
5. Measured results
Real ssh.exe cohorts, each dump used as the reference in turn. Reduce and
brute force ran with the built-in memory oracle (packet-residue for ChaCha,
derived-state for AES) on 2026-11-29; ranges are over the references.
Win10 x64 ChaCha |
Win11 ARM64 ChaCha |
Win11 ARM64 AES |
Win10 x64 AES |
|
|---|---|---|---|---|
Dumps (N) |
4 |
3 |
3 |
4 |
Reference layout |
|
|
|
|
References measured |
4 |
3 |
3 |
1 (session 1) |
Busy blocks of the reference |
2,792–2,794 |
2,709–2,731 |
2,742–2,757 |
2,801 |
Aligned rows |
1,515 |
1,481 |
1,551 |
1,511 |
L = bytes compared per dump |
399,896 |
363,224 |
580,053 |
472,800 |
Block bytes not compared |
57.8 % |
59.0 % |
34.5 % |
47.8 % |
Opaque areas |
0 |
0 |
0 |
0 |
Kept regions |
252–304 |
274–355 |
289–302 |
274 |
Kept bytes |
750,144–765,760 |
623,849–735,640 |
628,330–629,590 |
618,672 |
Brute-force windows (stride 1) |
734,601–749,492 (k = 64) |
607,864–717,245 (k = 64) |
619,541–620,460 (k = 32) |
610,671 (k = 32) |
Kept / reference memory |
≈ 2.7 % of ≈ 27.6 MB |
≈ 1.2–1.4 % of ≈ 52 MB |
≈ 1.2 % of ≈ 52 MB |
≈ 2.2 % of ≈ 27.6 MB |
Keys proven |
8/8 |
6/6 |
6/6 |
2/2 encryption keys; 2/2 MAC keys in a second run |
Reduce + brute force per run |
0.9–1.2 s |
1.1–5.8 s |
10.3–15.5 s |
5.3 s (CLI wall time); MAC run 612.7 s |
The reduce stage alone (all N parses, the consensus and the verdicts) took
0.2–0.4 s per run on the two ChaCha sets (not recorded for the AES sets). The Win10 x64 AES column is one pipeline run --method auto (which
resolved to windows_heap) with --oracle-kind derived-state: its default
aes chain proves the encryption keys (4 hits, 2 distinct keys, each in a
b48:s40 key buffer and a b272:s264 cipher context), and a second run with
the hmac-sha256 chain proves the two MAC keys (in b48:s40 blocks) from the
same 274 regions. That chain has no fast pre-screen, so every window is verified
with a full memory search, hence 612.7 s. The Win10 x64 ChaCha funnel for reference 1, as blocks /
bytes:
Verdict |
Blocks |
Bytes |
|---|---|---|
|
9 |
303,816 |
|
4 |
12,688 |
|
291 |
433,832 |
|
2 |
4,240 |
|
1,500 |
79,152 |
|
985 |
108,016 |
|
1 |
248 |
The kept bytes are dominated by a few large signature-unique blocks (9 blocks, 304 KB) and the dynamic candidates. Inside the heap the method keeps most of the reference’s block bytes (750 of 942 KB here); what it removes is everything outside the heap.
Positional baseline on the same dumps (reference 1, positional pipeline,
with a custom SSH memory-proof oracle for the ChaCha sets):
the Win10 x64 ChaCha run kept 86,115 regions / 5,200,642 bytes in 34.2 s and the
Win11 ARM64 ChaCha run 203,982 regions / 14,379,953 bytes in 89.3 s; neither
covered a session key (verdict ABSENT). windows_heap kept about 7× (x64)
and 20× (ARM64) fewer bytes and covered every key. On the Win10 x64 AES set the positional
pipeline kept 1,105 bytes at its floor, then 86,094 regions / 5,199,384 bytes in
its heap fallback, followed by floor-free escalation; no key was in its slab
and the run ended ABSENT after 306 s, against 5.3 s for windows_heap.
These numbers come from private run artifacts, not from a test. No validation check
covers the windows_heap pipeline: the optional checks on the private Windows 11
ARM64 and Windows 10 x64 ssh.exe minidumps (VALIDATION) cover the
vol3 plugins (memdiver.ssh, held-out synthesis, discover, the image --pid
route) on the same corpus.
6. Using it
Automatic selection
Every surface defaults to method = auto. With at least two dumps, auto
probes the first dump; if it is a Windows .msl, it probes every dump with the
block extractor and picks windows_heap only when every dump is a native
.msl with os = windows and at least one parsed heap block, else
positional. A first dump that is a non-Windows .msl goes to the Go heap
check instead. The result says why. auto always resolves to positional when a
positional-only option (N-sweep, plugin, explicit escalation, region filter,
reduce knobs including heap_policy) was given. Encrypted dumps are probed
decrypted when the run gets their key material (--key-file, --passphrase,
--kem-key-file; key_file / passphrase / kem_key_file elsewhere);
without it an encrypted Windows reference resolves to positional with
method.encrypted. An explicit method always wins. To see the choice without running anything:
memdiver pipeline suggest-method ssh_session1.msl ssh_session2.msl ssh_session3.msl ssh_session4.msl
(REST: POST /api/pipeline/method-suggestion; library and MCP:
suggest_pipeline_method.)
CLI: end to end
# Win10 x64 / Win11 ARM64 OpenSSH, chacha20-poly1305: 64-byte keys
memdiver pipeline run ssh_session{1,2,3,4}.msl --output-dir run_win \
--method windows_heap --heap-allocator auto \
--oracle-kind packet-residue --key-sizes 64
# aes256-ctr: 32-byte keys, schedule-backed proof
memdiver pipeline run ssh_aes{1,2,3}.msl --output-dir run_aes \
--method windows_heap --oracle-kind derived-state --key-sizes 32
# the HMAC-SHA2-256 keys of the same cohort (no pre-screen: much slower)
memdiver pipeline run ssh_aes{1,2,3}.msl --output-dir run_mac \
--method windows_heap --oracle-kind derived-state \
--oracle-param 'chain="hmac-sha256"' --key-sizes 32
The first dump is the reference. --heap-allocator {auto,segment_heap,nt_heap}
forces the parser that builds the layout; either parser composes the other
kind’s blocks, so both kinds are judged in any case. A value other than auto
is refused unless --method windows_heap is given explicitly (also under
--method auto). --key-sizes defaults to
32, which misses a 64-byte ChaCha20-Poly1305 key.
CLI: collect session
memdiver consensus-begin --state win.json --allocator windows_heap
for d in ssh_session{1,2,3,4}.msl; do memdiver consensus-add --state win.json "$d"; done
memdiver search-reduce --state win.json --reference-dump ssh_session1.msl \
--key-sizes 64 -o cand.json
memdiver brute-force --candidates cand.json --dump ssh_session1.msl \
--oracle my_oracle.py --key-sizes 64 -o hits.json
consensus-begin --allocator windows_heap takes no --size (both together are
refused with consensus.size_allocator_xor); consensus-add only records
paths, because the block consensus is built inside search-reduce.
search-reduce prints the verdict funnel and writes candidates.json to -o.
This route always uses the auto parser hint.
MCP, REST and library
MCP:
search_reduce_windows_heap(dump_paths, reference_path, output_dir, key_sizes=None, …, allocator="auto", mixed_ok=False, force_memory=None)writesoutput_dir/candidates.json;key_sizesdefaults to[32]. Orpipeline_runwithmethod="windows_heap"andheap_allocator.REST:
POST /api/pipeline/runwith"windows_heap": {"allocator": "auto"}(WindowsHeapParams;auto,segment_heapornt_heap) and/or"method": "windows_heap". Thewindows_heap,scudoandgo_heapobjects are mutually exclusive. The async runner builds the consensus inside its reduce stage and storessearch_reduce/candidates.json.Library:
from memdiver import services result = services.search_reduce_windows_heap( dump_paths=["s1.msl", "s2.msl", "s3.msl", "s4.msl"], reference_path="s1.msl", output_dir="out", key_sizes=(64,), allocator="auto") print(result["funnel"], result["totals"]) run = services.pipeline_run( dump_paths=["s1.msl", "s2.msl", "s3.msl", "s4.msl"], output_dir="run", oracle_kind="packet-residue", key_sizes=(64,), method="windows_heap", heap_allocator="auto")
Refusals and why
Code |
When |
|---|---|
|
fewer than 2 dumps |
|
a key size ≤ 0 |
|
a path is missing, or one dump is given twice |
|
a dump is not a native |
|
the reference is not one of the dumps |
|
the dumps come from different cohorts (override: |
|
an unknown parser hint, or a dump whose heap is not a Windows heap (names the detected allocator) |
|
the reference has a short captured run |
|
an explicit plugin request ( |
|
an explicit N-sweep, escalation, region filter or reduce option |
|
an encrypted dump without its key, before any byte is read |
Plugin generation and escalation are built on a per-byte variance along the reference’s address space, which this method does not have: it compares whole heap blocks across processes. When neither is requested, both are off for this method.
Diagnostics
Code |
Severity |
Meaning |
|---|---|---|
|
warning |
heap areas of the reference were not decoded into blocks and were not judged (by reason) |
|
info |
busy blocks with uncaptured user bytes were left out |
|
warning |
the parser hit its chunk cap |
|
warning |
kept blocks failed the translation to flat offsets |
|
info |
reference blocks whose signature is missing from some dump |
|
info |
nothing was kept, with the reason and the funnel |
Troubleshooting
Segment heap
HeapKeyrefused (no segments, inconsistent candidates, no VS subsegment to test, undecodable, ambiguous): VS ranges become opaque (winheap.opaque, reasonopaque_range) and are not judged. Backend blocks are still judged. Checkmemdiver heap summaryfor the named refusal.NT
RtlpLFHKeynot derived (layout diagnosticLFH: RtlpLFHKey not derived: …): subsegments are placed by the key-free fallback where possible; the rest becomelfh_subsegment_undecodedopaque areas. A key held there is not a candidate of this method.Segment heap
LfhKeynot unique: every LFH range becomes anopaque_rangearea. Small objects, including keys, are then not judged.Mixed allocators: a dump whose layout is not a Windows heap refuses the run (
winheap.wrong_allocator). Within a Windows dump both heap kinds are judged, so a forced--heap-allocatormainly changes which parser builds the layout and which kind wins an overlap.alignment.private_memory_not_comparableon a positional consensus: expected on Windows process cohorts; it is the reason to usewindows_heap(ormethod=auto). A positional pipeline run carries this warning in itswarningswhen it drops a heap, but stays silent when the dumps’ heaps have equal size and are compared at the same region key and page offset, which still compares unrelated bytes. So its absence does not mean the keys were compared. The warning’s remedy (details.remedy_code) follows how the run chose its method:explicit_positional(useautoorwindows_heap),positional_options(an option such as N-sweep forced positional; drop it) orno_heap_method(no heap method fits these dumps; use an anchor or keylog).Too many bytes not compared (coverage warning): large ambiguous signatures (for example many NT blocks of one bucket, whose
s<len>is the slot size, not the requested size) do not pair. Their per-run blocks are still kept as dynamic candidates; only the shared ones are dropped.
Not this method: positional heap_policy = user_data
The session or positional route with heap roles (--heap-policy annotate|mask|user_data, consensus-begin --size N --allocator auto|segment_heap|nt_heap) compares the dumps at the same flat offset and
uses the heap parsers only to label bytes; user_data keeps only bytes inside
heap user data. It is a different reduction with different numbers: on the
four Win10 x64 NT-heap dumps, at default thresholds, it kept every key that
off kept while cutting 86k regions / 5.2 MB to 174–192 regions / about 13 KB
(private run log, not a test). See
Session reduce on a Windows heap
and Consensus projection.
windows_heap does not use heap byte roles at all.
7. Limits and open issues
Free blocks are out of scope. A key in a freed LFH slot or a freed VS chunk is never a candidate here (unlike the Go heap method).
A missing signature removes blocks from judgement. A block whose signature is absent from any one dump (including a block with an uncaptured byte there) is
missingfor every reference. Dynamic candidates are found only inside ambiguous signatures.The NT
s<len>is an upper bound (stride − 8,Size·16 − 8). Blocks of different requested sizes share a signature and must be separated by content; usingrequested_sizemight pair better but is not measured.Pointer masking misses encoded pointers (
EncodePointer, heap-encoded headers) and 32-bit or unaligned pointers, which then look like per-run content; integers inside mapped ranges are over-masked.Variance is only
> 0versus0. No floor or threshold applies.Opaque paths are untested on real data. All real Windows sets here have 0 opaque areas after LFH decoding;
lfh_subsegment_undecodedandallocation_state_unknownare exercised by synthetic tests only.Unverified layouts: the segment heap
seg_19h1_22h2profile, the legacyHeapKeyvariant, large allocations in both heaps, the x64 segment heap, builds 21H2–23H2 and NT 1511–1809.Provenance not persisted. The per-signature dynamic-candidate lists are not written to
candidates.json.No plugin. A Volatility 3 plugin cannot be generated from this method.
No validation check covers the method; the measured numbers above are run artifacts and may change with more data.
8. Source map
Module |
Role |
|---|---|
|
OS gate, page-signature scan, PEB/TEB walk, heap roles |
|
NT heap discovery, chunks (backend, LFH blocks, opaque subsegments), layout |
|
|
|
LFH zones and subsegments, legal FAOs, |
|
NT structure offsets, front-end profiles, |
|
segment heap: layouts, backend, |
|
one layout per process (both heap kinds) |
|
blocks, opaque areas, block signature, |
|
shared engine: signature pairing, pointer mask, content pairing, slab |
|
slab layout and per-byte variance |
|
verdict rule and funnel |
|
producer |
|
input validation, translation to |
|
refused options, automatic method selection |
|
CLI surfaces |
|
MCP tool and REST parameters |