Skip to content

GdprMode.Strict warns that deleted documents are not zeroed, but every delete zero-fills them #299

Open

Description

@CaffeinatedCoder

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 times

Expected: 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.DeleteCore compacts 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.FreePage writes 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.
  • VacuumAsync with VacuumOptions.SecureErase (default true) 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

Related: #96 (slot-level secure erase), #113 (GdprMode.Strict), #296 section 8, #298.

Activity

  1. moved this from Todo to In Progress in BLiteon Oct 18, 2026
  2. added
    severity/lowCosmetic, ordering or documentation-level difference
    and removed on Oct 18, 2026
  3. mrdevrobot commented on Oct 18, 2026

    @mrdevrobot
    Contributor

    Verified on 0450b97: deletes do zero-fill, so the 9006 text is wrong. Text and docs only: low.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggdprGDPR compliance primitivespackage/coreAffects BLite.Coreseverity/lowCosmetic, ordering or documentation-level difference

    Type

    No type

    Projects

    • Status
      In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions