Open haaawk opened 4 months ago
What we noticed is that this issue happens when SQLite3 Multiple Ciphers cipher type is set to sqlcipher
. It doesn't happen when aes256cbc
is set.
Potential reason may be that the latter (working one) doesn't use HMAC, while former may interfere with Frame Injector at this edge. From the documentation:
The cipher does not use a Hash Message Authentication Code (HMAC), and requires therefore no reserved bytes per database page.
sqlcipher - the failing one:
he encryption key is derived from the passphrase using a random salt (stored in the first 16 bytes of the database file) and the standardized PBKDF2 algorithm with an SHA1, SHA256, or SHA512 hash function. A random 16 bytes initial vector (nonce) for the encryption of each database page is used for the AES algorithm. Additionally, an authentication tag per database page is calculated: SQLCipher version 1 used no tag (0 bytes). SQLCipher version 2 to 3 used a SHA1 tag (20 bytes). SQLCipher version 4 uses a SHA512 tag (64 bytes), allowing to optionally choose a SHA256 tag (32 bytes) instead. Therefore this cipher requires 16, 48 or 80 reserved bytes per database page (since the number of reserved bytes is rounded to the next multiple of the AES block size of 16 bytes).
Reproducer:
Observed problem:
It seems that we are not able to open encrypted embedded replica.
The problem goes away after applying the following patch and repeating the reproducer steps: