Executing user-supplied SQL over HTTP is the highest-risk surface in Litebase. We treat any bypass of our authorization, SQL authorizer, or filesystem isolation boundaries as a critical security issue.
Litebase enforces the following security invariants across all connections and requests:
- SQLite Authorizer (
sqlite3_set_authorizer):- Denies
ATTACH,DETACH,load_extension, andfts3_tokenizer. - Denies direct mutations of internal
_litebase_*tables. - Restricts
PRAGMAstatements to a read-only inspection allow-list (table_info,index_list,index_info,foreign_key_list,integrity_check,wal_checkpoint,page_count,page_size,freelist_count).
- Denies
- Read-Only Pool Enforcement:
- Reader pool connections open SQLite with
mode=roandPRAGMA query_only = ON, and install a read-only authorizer that rejects all write operations.
- Reader pool connections open SQLite with
- Scoped Token Authentication:
- Bearer tokens (
lbk_<64-hex>) contain 256 bits of cryptographic entropy (crypto/rand). - Only SHA-256 hashes are stored in
control.dband compared in constant time (crypto/subtle.ConstantTimeCompare).
- Bearer tokens (
- Filesystem Path Containment:
- Database, branch, and snapshot names are validated against
^[a-z0-9][a-z0-9_-]{0,62}$and checked withengine.SafeJoinPathto prevent path traversal (../, null bytes, or symlink escapes).
- Database, branch, and snapshot names are validated against
Please do not open a public GitHub issue for security vulnerabilities.
Instead, report vulnerabilities privately via GitHub Security Advisories and include:
- The affected component (
internal/engine,internal/api,internal/auth,internal/cli, etc.) - A minimal proof-of-concept request or SQL payload reproducing the issue
- The potential impact (e.g., authorizer bypass, privilege escalation from
readtowrite/admin, path traversal, or denial of service)