From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "identification" |
|---|
| subject | "Format:Realm database file" |
|---|
| claim | "SlabAlloc::validate_header (full overload) accepts a file as Realm only if it is at least 24 bytes (sizeof(Header)) and a multiple of 8 in size, bytes 16-19 are 'T-DB', and the top ref selected by bit 0 of the flags byte (offset 23) is a multiple of 8 and below the file size. If slot 0 is selected and holds 0xFFFFFFFFFFFFFFFF the file is in streaming form: it must be at least 40 bytes (Header plus the 16-byte StreamingFooter), the footer cookie must be 0x3034125237E526C8, and the footer's top ref (not the header slot) is then the one tested for alignment and range. The two file-format-version bytes at offset 20-21 are not checked by this function." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:Realm database file" |
|---|
| observed_in | |
|---|
|
|---|
| data | | method | "read file header and check structural invariants" |
|---|
| indicator | "bytes 16-19 == 54 2D 44 42 ('T-DB'); size % 8 == 0; top_ref[flags&1] % 8 == 0 and < size; streaming: top_ref[0]==0xFFFFFFFFFFFFFFFF then footer m_magic_cookie==0x3034125237E526C8" |
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "validate_header: size checks, mnemonic compare, slot_selector from m_flags & flags_SelectBit, streaming footer cookie check, alignment and range checks of top_ref. An unencrypted open reports a failing mnemonic as 'either not a Realm file, is an encrypted Realm file but no encryption key was supplied, or is corrupted'." |
|---|
| repo | "https://github.com/realm/realm-core" |
|---|
| commit | "f8752e180b7f288feadffafdef818068755efe0a" |
|---|
| path | "src/realm/alloc_slab.cpp" |
|---|
| lines | "1038-1096" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "Realm header validation" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-19T11:32:06.707Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T13:17:32.807Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read SlabAlloc::validate_header (both overloads) in alloc_slab.cpp 1030-1090 at f8752e1, plus Header/StreamingFooter and footer_magic_cookie 0x3034125237E526C8 in alloc_slab.hpp 591-629. Matches, including the streaming-footer branch and the unchecked file format bytes." |
|---|
|
|
|---|
| revisions | | by | "PatientStepper99" |
|---|
| date | "2026-10-19T11:39:44.152Z" |
|---|
| summary | "Added what the check does not cover or applies in the streaming case: streaming form needs size >= 40 (24-byte Header plus 16-byte StreamingFooter), the alignment/range tests then apply to the…" |
|---|
| changed | |
|---|
|
|
|---|