At the end of my earlier post on navigating the SQLite freeblock chain, we ran into a deleted message that wasn’t in the freeblock chain at all. The page header said there were two live records, the freeblock chain gave us two deleted ones, and sitting just above the cell content area was a fifth message waiting to be overwritten.
Freeblocks are usually where people start with SQLite recovery because SQLite does the navigation work for you. Offset 1 in the page header gives you the location of the first freeblock, and each freeblock starts with a 4-byte header giving the offset to the next one and its size. Walk the pointers and you find every block in the chain.
Unallocated space is a different problem. It sits on the very same page, right between the cell pointer array and the cell content area, and no pointer in the database tracks what is inside it. There is no chain, no record count, and no size header. Based on the page header alone, you have no way of knowing whether that gap holds ten records, one partial fragment, or 3,900 bytes of zeros.
Let’s walk through where unallocated space sits on a page, four common ways records end up there, how SQLite’s version changes what survives, and how to validate what you find before it goes into a forensic report.
Finding the Boundaries of Unallocated Space
SQLite fills a table leaf page (0x0D) from both ends toward the middle:
- Top down: A table leaf page has an 8-byte B-tree header. On Page 1, it follows the 100-byte database file header, so the cell pointer array (2 bytes per live record) begins at byte 108.
- Bottom up: The actual records (cells) are written from the bottom of the page upward toward the top.
Everything in between those two regions is unallocated space.
Two values in the page header give you its exact byte range:
| Header Offset | Size | What It Tells You |
|---|---|---|
| Offset 3 | 2 bytes | Number of live cells on the page. Multiply by 2 and add 8 for the leaf B-tree header (or add 108 on Page 1, accounting for the 100-byte file header). That byte offset is where the cell pointer array ends and unallocated space begins. |
| Offset 5 | 2 bytes | Start of the cell content area. Marks the first byte of the active cell region, which is where unallocated space ends. |
In the test database we’ll decode below, Page 2’s header reports 3 cells and a cell content start offset of 0x0F88 (decimal 3,976). Three 2-byte pointers after an 8-byte header puts the end of the pointer array at byte 8 + 6 = 14. That means bytes 14 through 3,975 (3,962 bytes in total) are unallocated space.
That is all the metadata SQLite gives you. To see whether anything is inside those 3,962 bytes, you have to inspect the raw data.
Four Ways Records End Up in Unallocated Space
While we were building and testing the Unallocated Space carver in Firefly, I wanted to verify every path that puts record data into this gap across older and newer builds of SQLite. Running controlled tests across SQLite 3.8.5, 3.39.2, and 3.50.4 showed four distinct scenarios. These examples use PRAGMA secure_delete = OFF and describe bytes remaining before subsequent reuse or reorganization:
Deleting the record at the top of the cell content area.
Because cells are written from the bottom of the page upward, the most recently written record on a page usually sits right at the start of the cell content area (the lowest offset). When that record is deleted, SQLite doesn’t add it to the freeblock chain. Instead, it moves the cell content start offset (header offset 5) down past the deleted cell. Those bytes are now sitting in unallocated space.Absorbing an adjacent freeblock.
If a deleted record at the start of the content area sits right in front of an existing freeblock, SQLite merges them and moves the cell content boundary past both. That older freeblock gets pulled out of the freeblock chain and drops into unallocated space, still carrying its 4-byte freeblock header even though the chain no longer points to it.Deleting every row from a table without a
WHEREclause.
When an app runsDELETE FROM messages;with noWHEREclause, SQLite can use its truncate optimization (triggers,RETURNING, and application or build settings can affect whether that path is used). On a single-page table, SQLite resets the 8-byte page header to zero cells and leaves the rest of the page untouched. In my test table, all six records (and even their old 2-byte cell pointers right after byte 8) remained intact in unallocated space, byte for byte. On a multi-page table, the root page resets like this while the child pages move to the freelist.B-tree page splits, with zero deletions.
This is the one that catches people off guard. When a table outgrows a single leaf page, SQLite allocates new pages, redistributes the cells, and converts the original page into an interior page. Old cells that moved elsewhere are often left behind in that page’s unallocated space. In one test, I inserted 200 rows into a brand-new table and deleted nothing. Afterward, 80 of those rows had a second, intact copy sitting in unallocated space, even though all 80 were still live rows in the table.
Keep that fourth scenario in mind when we get to reporting, because it directly affects what you can conclude from the bytes.
Why the SQLite Version Changes What Survives
In the first two scenarios above, what survives at the beginning of the deleted record depends on which version of SQLite performed the deletion:
- SQLite 3.42.0 and newer: Beginning with SQLite 3.42.0,
freeSpace()skips writing the 4-byte freeblock header when freed space is absorbed into the unallocated region. WithPRAGMA secure_delete = OFF, our 3.50.4 example retains the whole cell, including the payload length and rowid. - SQLite 3.41.x and older: In SQLite 3.39.2 and 3.41.2,
freeSpace()advances the cell content boundary first, then still writes a 4-byte freeblock header (next-block pointer and block size) afterward. Even though the record is now in unallocated space rather than the freeblock chain, its first 4 bytes (typically the payload length, rowid, and start of the record header) are overwritten.
You can check which version of SQLite last wrote to the database by reading the 4-byte big-endian integer at file offset 96 in the database header. For example, 3039002 means SQLite 3.39.2. This identifies the library that most recently modified the database file; it does not prove which version performed a particular earlier deletion.
Why Data Here Is Fragile
A later insert into the same page can overwrite some or all of those bytes.
Page defragmentation can also wipe it all at once. When a page has enough total free bytes to fit a new record, but those bytes are scattered across freeblocks, SQLite compacts the live cells at the bottom of the page and zeroes out the unallocated gap. In my test database, a single insert that triggered defragmentation wiped 21 deleted records on that page in one operation: one in unallocated space and 20 in freeblocks. And if PRAGMA secure_delete is enabled, SQLite zeroes deleted bytes immediately upon deletion.
Why Unallocated Space Is Harder Than a Freeblock
Compare what SQLite gives you in each region:
| Question | Freeblock Chain | Unallocated Space |
|---|---|---|
| Where freed space starts | Freeblock offset given by the chain | Unmarked |
| How long the block is | 2-byte size field in the freeblock header | Unmarked |
| How many blocks exist | Walk the freeblock chain until 0x0000 |
Unmarked |
| Condition of the record | A 4-byte header at the start of the freeblock; surviving record bytes depend on merging, reuse, and secure-delete settings | Intact, missing its first 4 bytes, or truncated by a newer write |
Freeblock boundaries are not guaranteed record boundaries. Merging, reuse, and secure-delete settings affect which record bytes survive.
A keyword search will find the text of a chat message inside unallocated space, but it won’t tell you where the record begins, which sender or timestamp belongs with that text, or whether you are looking at a complete record or the tail end of an overwritten one. To prove those fields belong together, you have to validate the SQLite record structure.
Reconstructing a Record by Hand
Here is a small test database you can rebuild yourself (example_3504.db, 4,096-byte pages, with messages on Page 2 starting at file offset 0x1000):
PRAGMA page_size = 4096;
PRAGMA secure_delete = OFF;
CREATE TABLE messages(id INTEGER PRIMARY KEY, sender TEXT, body TEXT, sent INTEGER);
INSERT INTO messages VALUES(1, 'Dana', 'Are we still on for Friday?', 1795197851);
INSERT INTO messages VALUES(2, 'Rob', 'Yes. Same place as last time.', 1795197946);
INSERT INTO messages VALUES(3, 'Dana', 'Bring the paperwork.', 1795198022);
INSERT INTO messages VALUES(4, 'Rob', 'Delete this when you have read it.', 1795198087);
DELETE FROM messages WHERE id = 4;
After message 4 is deleted under SQLite 3.50.4, a standard database viewer shows three rows. Opening Page 2 in Hex Workbench shows the first 16 bytes at file offset 0x1000 (page offset 0x0000):
0000: 0D 00 00 00 03 0F 88 00 0F D6 0F AB 0F 88 0F 58
0D(offset 0): Table B-tree leaf page.00 00(offset 1): First freeblock offset. Zero means the freeblock chain is empty.00 03(offset 3): Three live cells on this page.0F 88(offset 5): Cell content area starts at page offset0x0F88(3,976).0F D6,0F AB,0F 88(offsets 8 to 13): The three active cell pointers.
Look at the two bytes right after the third pointer at page offset 0x0E (file offset 0x100E): 0F 58. Because the live cell count dropped from 4 to 3, those two bytes now sit inside unallocated space, yet they still hold the offset of the deleted fourth cell: 0x0F58 (decimal 3,928).
Caution with leftover pointers: Treat old pointer bytes as a lead, not proof. When SQLite deletes a pointer from the middle of the pointer array, it shifts the remaining pointers left, leaving a duplicate copy of the last live pointer at the end of the array.
Jumping down to page offset 0x0F58 (file offset 0x1F58), immediately above the active cell content area at 0x0F88, here is what sits in the gap:
0F58 2E 04 05 00 13 51 04 52 6F 62 44 65 6C 65 74 65 .....Q.RobDelete
0F68 20 74 68 69 73 20 77 68 65 6E 20 79 6F 75 20 68 this when you h
0F78 61 76 65 20 72 65 61 64 20 69 74 2E 6B 00 8C 87 ave read it.k...
0F88 21 03 05 00 15 35 04 44 61 6E 61 42 72 69 6E 67 !....5.DanaBring
Decoding the cell byte by byte gives us every column:
| Bytes | Field / Meaning |
|---|---|
0x2E |
Payload length varint: 46 bytes (everything after the rowid). |
0x04 |
Rowid varint: 4. |
0x05 |
Record header length varint: 5 bytes total, including this length byte. |
0x00 |
Column id serial type: 0 (NULL, because an INTEGER PRIMARY KEY aliases the rowid rather than storing a second copy in the payload). |
0x13 |
Column sender serial type: hex 0x13 is decimal 19. For odd integers >= 13, UTF-8 text length is (19 - 13) / 2 = 3 bytes. |
0x51 |
Column body serial type: hex 0x51 is decimal 81, giving (81 - 13) / 2 = 34 bytes of text. |
0x04 |
Column sent serial type: 4 = 4-byte big-endian signed integer. |
52 6F 62 |
sender: "Rob" (3 bytes). |
44 65 ... 74 2E |
body: "Delete this when you have read it." (34 bytes). |
6B 00 8C 87 |
sent: 0x6B008C87 = 1795198087 (2026-11-20 18:08:07 UTC). |
Three structural checks turn this from a string hit into a verified SQLite record:
- Schema fit: Serial types
NULL, TEXT, TEXT, INT32match(id, sender, body, sent)in order. - Length math: The 5-byte header plus the column values (
0 + 3 + 34 + 4 = 41bytes) equals 46 bytes, matching payload length0x2E. - Clean boundary: Adding the 1-byte payload length and 1-byte rowid gives a 48-byte cell (
0x30).0x0F58 + 0x30 = 0x0F88, landing cleanly on the first byte of live cell 3 with no overwrite at the tail.
If there is no leftover pointer to guide you, work backward from the readable text: find the first byte of the first string value, inspect the bytes immediately before it for a header length and serial-type varints whose byte counts add up, and read the rowid and payload length varints right in front of that header.
The Same Deletion Under SQLite 3.39.2
Running the exact same SQL script under SQLite 3.39.2 (example_3392.db) produces a different first line at 0x0F58:
0F58 00 00 00 30 13 51 04 52 6F 62 44 65 6C 65 74 65 ...0.Q.RobDelete
Even though the page header still reports 00 00 for the freeblock chain, freeSpace() in SQLite 3.39.2 advanced the content boundary and still wrote a 4-byte freeblock header over the start of the cell afterward: 00 00 (no next block) and 00 30 (48 bytes).
"Rob", "Delete this when you have read it.", and 1795198087 all survive, and 0x0030 confirms the cell occupied 48 bytes. What is gone is the rowid. Nothing in these bytes can prove anymore that this was message ID 4.
For more practice with SQLite structures, recovery, and validation at the page and byte level, see our SQLite Forensics On-Demand course.
What You Can and Cannot Say in Your Report
Recovering the record is half the job. Defending what it means in a report or a courtroom requires separating what the bytes establish from what people often assume.
What the bytes establish:
- These exact bytes sit in this file, on Page 2, at file offset
0x1F58. - They form a valid SQLite record structure containing
"Rob","Delete this when you have read it.", and1795198087. - That structure fits the columns of the
messagestable.
What the bytes do NOT establish on their own:
- That a user deleted the row. Remember the page-split test: 80 intact records sitting in unallocated space, all 80 still live in the active table. Finding a record in unallocated space proves SQLite wrote it to that page at some point, not that a user removed it.
- When it stopped being active.
1795198087is the message’ssenttimestamp, not a deletion timestamp. SQLite stores no deletion time in unallocated space. - Exclusive table ownership when schemas match. If two tables in the database share compatible column affinities (for example,
messagesandarchived_messages), the raw bytes fit both.
The Cross-Check to Run Every Time
Before writing “deleted” in a report, check the carved record against the active table (and the WAL, if present):
| What the Live Table Holds | What It Indicates |
|---|---|
| Same rowid and same values | A matching row is currently live. This is consistent with a leftover copy from a page split or reorganization, but the match alone does not establish the copy’s history. |
| Same rowid with different values | Earlier version of an updated row, or a deleted row whose rowid was reused. |
| Neither that rowid nor those values | Consistent with a deleted row (when the rowid was overwritten, compare the surviving values). |
Report the finding for what it is: a record recovered from unallocated space on Page 2 at file offset 0x1F58, in a file with this SHA-256 hash. That is a finding another examiner can check against the source. Saying “the user deleted this message” requires supporting context beyond those 48 bytes.
Scaling This Workflow in Firefly
Doing this math by hand on one 4 KB page is the best way to understand how SQLite works and to verify a critical artifact, but real mobile databases routinely span thousands of pages. We built the Unallocated tab in Firefly to handle that scale while keeping the exact same forensic discipline.
- Shows you where surviving bytes sit: Every page is drawn as a visual map of headers, pointers, live cells, freeblocks, zeroed unallocated space, and non-zero unallocated space (in green). Ticking Only pages with unallocated bytes not zero hides empty pages immediately.
- Validates records the same way you do by hand: Clicking Analyze Unallocated Space tests non-zero unallocated bytes in the database file against the rowid table schemas, checking intact cells, 4-byte-overwritten remnants, and cells truncated at the tail by newer writes.
- Separates complete records from partial remnants: Running Firefly on our two test files produces two distinct classifications at
0x1F58:- SQLite 3.50.4 (
example_3504.db): Carved as a whole cell ofmessages(id = 4,"Rob","Delete this when you have read it.",1795198087) with status Complete. - SQLite 3.39.2 (
example_3392.db): Carved as a 4-byte-overwritten remnant with"Rob", the message body, and timestamp intact,id/ rowid marked Unavailable, and status Partial (preventing an incomplete remnant from being added silently as a full table row).
- SQLite 3.50.4 (
- Keeps full byte provenance: Double-clicking any carved row opens its Carved record provenance sheet with the file’s SHA-256, method version, field-by-field decode notes, and exact byte span. One click opens those bytes directly in Hex Workbench.
On our 200-row page-split database, Firefly carves those 80 intact leftover copies as Complete whole records (plus Row ID 1 as Partial where the interior cells overwrote its trailing bytes) and states plainly that unallocated carving does not prove deletion. You can add Complete records alongside live rows (marked Source: Unallocated) so you can run the live-table comparison yourself in context.
Tools should save you from scanning ten thousand pages by hand, not ask you to take decoded output on faith. Walk through a page or two manually first, and you will know both what your tool is finding in unallocated space and what those bytes actually support.
Read more about Firefly and book a demonstration on the Firefly page.




