Repository navigation
Encrypt WAL frames below another VFS shim, add a VFS stack test - #312
Merged
Merged
Conversation
sqlite3mcPagerCodec, which encrypts the page content for the WAL, only used the codec if the pager's file had the methods of the Multiple Ciphers VFS. With another VFS shim above it that wraps the files, the pager's file is the shim's, so the frames were written to the WAL in plaintext, and the database could not be read again after a checkpoint. Ask the file for its codec with SQLITE3MC_FCNTL_PCODEC instead, as sqlite3mcPagerHasCodec already does; the file control passes through shims.
test/vfsstacktest.c runs the same steps with the Multiple Ciphers VFS alone, below one and two pass-through VFS shims that wrap every file, and twice in the stack: create an encrypted database, WAL, ATTACH with KEY and with URI parameters, rekey, cipher change (through VACUUM), decrypt and encrypt again. After every step the database must open with the expected key, and no file may contain the plaintext of the rows.
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.
With another VFS shim above the Multiple Ciphers VFS that wraps the files, WAL frames were written in plaintext, and after a checkpoint the database could not be read again. sqlite3mcPagerCodec, which encrypts the page content for the WAL, only used the codec if the pager's file had the methods of the Multiple Ciphers VFS; with a shim above it, the pager's file is the shim's. It now asks the file for its codec with SQLITE3MC_FCNTL_PCODEC, as sqlite3mcPagerHasCodec already does; the file control passes through shims.
test/vfsstacktest.c (CI step "VFS stack tests") runs the same steps with the Multiple Ciphers VFS alone, below one and two pass-through VFS shims that wrap every file, and twice in the stack: create an encrypted database, WAL, ATTACH with KEY and with URI parameters, rekey, cipher change (through VACUUM), decrypt and encrypt again, with chacha20, aes256cbc, sqlcipher and aegis. After every step the database must open with the expected key, and no file may contain the plaintext of the rows.
Testing (macOS arm64, flags from Makefile.am):