fix(cpp): bind native ATTACH/DETACH parameters and use SQLCipher key API#409
Merged
ospfranco merged 2 commits intoMay 19, 2026
Merged
Conversation
Contributor
Author
|
The zero byte checks might be too much - I am just paranoid doing these sort of changes. |
Contributor
|
Cool, thanks! |
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
Hardens four native bridge surfaces that previously concatenated user-controlled values into SQL:
ATTACH DATABASE ? AS ?,DETACH DATABASE ?). SQLite, libsql, and Turso all accept binding in both the path slot and the schema-name slot, so no escape logic is needed at all.PRAGMA key = '<key>'to thesqlite3_key_v2C API.CMakeLists.txt— orderscpp/sqlcipherahead ofcpp/on the include path so the SQLCipher header (not the plain SQLite header) wins underUSE_SQLCIPHER. Latent before this change because nothing referenced SQLCipher-only symbols; required now forsqlite3_key_v2to link.Security framing
Not all of the above are security fixes; the diff is more honest if labelled:
'; ATTACH DATABASE '/tmp/evil.db' AS x; --) and in ATTACH/DETACH aliases. If those inputs were ever attacker-influenced (URL, deep link, IPC payload), the pre-fix code would have executed arbitrary SQL on the connection. The C API and parameter binding kill that.Notes
Turso attach/detach code was updated for parity, but the example tests keep the existing Turso skip because ATTACH support is not currently exercised there.