I was looking into implementing my own SQLite encryption VFS, however, I identified the following problems that your implementation also suffers from and does not tackle.
-
In WAL mode the frame header contains a rolling checksum over plaintext page data. This is an information leak and might totally break your protocol. The frame header is not encrypted.
|
static int mcWriteWal(sqlite3_file* pFile, const void* buffer, int count, sqlite3_int64 offset) |
-
Same problem in default, rollback-journal, mode, every page of the rollback journal contains a checksum over the plaintext data of the journal page, you just write this to disk unencrypted.
|
static int mcWriteMainJournal(sqlite3_file* pFile, const void* buffer, int count, sqlite3_int64 offset) |
-
And lastly, in WAL mode, SQLite will possibly write a page in 2 pieces to disk, your logic will write these 2 pieces of a page unencrypted to disk see
https://github.com/sqlite/sqlite/blob/c81ab76cd9f2ec77cb9e1219b504d741845a0703/src/wal.c#L3891
I've basically concluded it's near impossible to write a safe encryption VFS. There is not enough context in the VFS to make sound decisions about what data to encrypt or not.
I was looking into implementing my own SQLite encryption VFS, however, I identified the following problems that your implementation also suffers from and does not tackle.
In WAL mode the frame header contains a rolling checksum over plaintext page data. This is an information leak and might totally break your protocol. The frame header is not encrypted.
SQLite3MultipleCiphers/src/sqlite3mc_vfs.c
Line 1031 in 06838d2
Same problem in default, rollback-journal, mode, every page of the rollback journal contains a checksum over the plaintext data of the journal page, you just write this to disk unencrypted.
SQLite3MultipleCiphers/src/sqlite3mc_vfs.c
Line 935 in 06838d2
And lastly, in WAL mode, SQLite will possibly write a page in 2 pieces to disk, your logic will write these 2 pieces of a page unencrypted to disk see
https://github.com/sqlite/sqlite/blob/c81ab76cd9f2ec77cb9e1219b504d741845a0703/src/wal.c#L3891
I've basically concluded it's near impossible to write a safe encryption VFS. There is not enough context in the VFS to make sound decisions about what data to encrypt or not.