[Bug] SingleFile (.scdb) mode ignores DatabaseOptions.EncryptionKey, writing data in plaintext - #342
Open
saltus7 wants to merge 2 commits into
Open
[Bug] SingleFile (.scdb) mode ignores DatabaseOptions.EncryptionKey, writing data in plaintext#342saltus7 wants to merge 2 commits into
saltus7 wants to merge 2 commits into
Conversation
added 2 commits
August 28, 2026 22:00
- Added test.runner config to global.json for MTP-native dotnet test - Build succeeds (291 warnings, non-fatal) - All 2,404 tests pass, 16 skipped, 0 failed
…writing data in plaintext
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Fixes a critical bug where SingleFile (.scdb) storage mode ignored
DatabaseOptions.EncryptionKey, writing data in plaintext even when encryption was configured.Root Cause
The
SingleFileStorageProvideraccepted the encryption configuration but never instantiatedAesGcmEncryptionor intercepted the I/O paths. Consequently,WriteBlockAsync,ReadBlockAsync,GetReadSpan, andGetReadStreamoperated directly on the rawFileStream, bypassing encryption entirely. (Directory mode was unaffected as it correctly wiredICryptoServiceviaDatabase.Core.cs).Changes
src/SharpCoreDB/DatabaseExtensions.cs: ResolvesICryptoServicefrom DI when encryption is enabled and passes it to the SingleFile provider.src/SharpCoreDB/Storage/SingleFileStorageProvider.cs: WiresAesGcmEncryptioninto the provider and intercepts all block read/write/stream paths to encrypt/decrypt data at rest.tests/SharpCoreDB.Tests/Security/SingleFileEncryptionTests.cs: Adds a comprehensive 12-test regression suite covering plaintext-at-rest, correct-key roundtrip, wrong-key rejection, and file integrity.src/SharpCoreDB/DatabaseOptions.cs,src/SharpCoreDB/SingleFileTable.cs,src/SharpCoreDB/Storage/Scdb/SingleFileDatabase.Batch.cs: (Included from local build/test adjustments).Also included
global.json(root): Addedtest.runnerconfig for MTP-nativedotnet teston .NET 10 SDK. Without this,dotnet testfails witherror Testing with VSTest target is no longer supported.Fixes #341
Verification