Repository navigation
GdprMode.Strict warns that deleted documents are not zeroed, but every delete zero-fills them #299
Description
Opening a database with GdprMode.Strict traces this warning (event 9006):
GdprMode.Strict: SecureEraseOnDelete is not yet available as an engine-level setting. Deleted document slots are not currently zeroed at the page layer. Track MISSING_FEATURES.md §3 for the planned implementation.
The second sentence is not true. Both delete paths zero-fill the bytes a deleted document occupied, and they have done so since #96 (646d940, 2026-04-29), five days before the warning was added in #113 (01ad3fa, 2026-05-04). A team doing a GDPR review reads the warning, concludes that erasure needs extra work, and asks the wrong question. docs/DPIA_CHECKLIST.md adds a third answer ("call VacuumAsync after deletion").
Found while compiling and running the README samples for #298.
Repro
// 1. The warning
Trace.Listeners.Add(listener);
using var strict = new BLiteEngine("strict.db", new CryptoOptions("pw"),
new BLiteKvOptions { DefaultGdprMode = GdprMode.Strict });
// traced: "[BLite GDPR EventId:9006] ... Deleted document slots are not currently zeroed ..."
// 2. What a delete does (plaintext, so the bytes are visible in the file)
const string Marker = "ZZ-PERSONAL-MARKER-7f3a9c-ZZ";
// typed context: insert { Name = "keep-me" }, { Name = Marker } and { Name = ~40 KB with Marker 40 times } (overflow pages),
// SaveChangesAsync, dispose → Marker occurs 41 times in typed.db
// reopen, DeleteAsync both, SaveChangesAsync, dispose → 0 times in typed.db and typed.wal
// BLiteEngine: insert { name = Marker }, CommitAsync, CheckpointAsync, close → 1 time in dyn.db
// reopen, DeleteAsync, CommitAsync, close (no checkpoint) → still 1 time in dyn.db
// reopen, CheckpointAsync, close → 0 timesExpected: the warning describes what the engine does, or is not emitted.
Actual: it says deleted slots are not zeroed; they are.
Where in the code (0450b97)
- Warning:
src/BLite.Core/GDPR/GdprStrictValidator.cs:101-107. - Typed delete:
DocumentCollection.DeleteCorecompacts the page and clears the free area (src/BLite.Core/Collections/DocumentCollection.cs:3495-3503, "Secure erase: zero-fill the free space area so the deleted document bytes are unrecoverable at the page level"). - Dynamic delete:
DynamicCollection.DeleteSlot→SlottedPageUtils.CompactAndErase(src/BLite.Core/DynamicCollection.cs:2688-2689). - Overflow pages of a deleted typed document go through
FreeOverflowChain→FreePageOnCommit;PageFile.FreePagewrites a new zero buffer with only the Free header (src/BLite.Core/Storage/PageFile.cs:1130-1144). That is why all 40 copies in the overflow pages are gone. VacuumAsyncwithVacuumOptions.SecureErase(defaulttrue) zero-fills the free space of every data page (src/BLite.Core/VacuumOptions.cs:14).
What is true, and could replace the warning
The one real caveat is timing. A delete writes the zeroed page through the WAL; the database file gets it at the next checkpoint. Until then the .db file still holds the deleted bytes (seen above for BLiteEngine, which does not checkpoint on dispose; DocumentDbContext does). So a warning, if any, would say: "Deleted documents are zero-filled on their page; the database file holds the old bytes until the next checkpoint. Call CheckpointAsync after deleting personal data." Encryption at rest, which Strict mode requires, already makes those bytes unreadable without the key.
Suggested fix
- Remove event 9006, or reword it to the checkpoint caveat above.
- Drop the pointer to
MISSING_FEATURES.md §3; Epic: v6.0.0 — migration guide, changelog, docs, samples and release engineering #296 section 8 proposes deleting that file because everything in it has shipped. - Align
docs/DPIA_CHECKLIST.mdand the README (done in docs(readme): show only APIs that exist in the source #298) on the same answer. - A test that holds it: the GDPR row of the oracle plan in Epic: reliability before features — durability, AOT, query correctness and oracle coverage #288 ("secure erase leaves no bytes of the erased document in the file"), with a checkpoint before the scan.
Related: #96 (slot-level secure erase), #113 (GdprMode.Strict), #296 section 8, #298.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn Progress
Activity
mrdevrobot commentedon Oct 18, 2026
Verified on 0450b97: deletes do zero-fill, so the 9006 text is wrong. Text and docs only: low.
docs(gdpr): only DocumentDbContext.DisposeAsync checkpoints (EntglDb#299