Skip to content

sqlite3mcSecureZeroMemory called with wrong argument count in mcMemoryFree; memset used instead of secure wipe in all Free*Cipher functions #230

@rajsin31415

Description

@rajsin31415

Bug 1: 3-argument call to 2-parameter function
In sqlite3mc_amalgamation.c line 335796:

sqlite3mcSecureZeroMemory(pPrior, 0, nSize);
sqlite3mcSecureZeroMemory takes (void*, size_t) — two parameters. The 0 is interpreted as the size, making this a zero-byte wipe (no-op). nSize is silently ignored. This means the entire SQLITE3MC_SECURE_MEMORY free path wipes nothing.

Fix: sqlite3mcSecureZeroMemory(pPrior, nSize);

Bug 2: Plain memset on key material before sqlite3_free
All Free*Cipher functions (FreeAES128Cipher, FreeAES256Cipher, FreeChaCha20Cipher, FreeSQLCipherCipher, FreeRC4Cipher, FreeAscon128Cipher, FreeAegisCipher) and sqlite3mcCodecTerm use memset() to clear key material (m_key, m_hmacKey, m_salt, Rijndael state) before freeing. Compilers are permitted to elide memset on dead stores (memory freed immediately after), so key material may persist in freed heap memory.

These should use sqlite3mcSecureZeroMemory instead.

Affected lines (approximate, in amalgamation): 329041, 329043, 329334, 329336, 329599, 330043, 330045, 330486, 331894, 332369, 332909, 332916.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions