WhoDB CE unauthenticated session forgery through sample SQLite filesystem access
Description
Scope
This vulnerability affects WhoDB Community Edition (CE) server deployments starting with 0.121.0, when the encrypted SQLite session store was introduced. The complete exploit was reproduced against clidey/whodb:0.122.0 (digest sha256:61159d9089222b3c725037cf543a462a3c859eb50fd14dfceab7a30dbac45229). Static review confirms that the vulnerable path remains in 0.131.0 and current main before the pending fix.
The demonstrated session-forgery chain does not affect Enterprise Edition (EE): EE disables the CE SQLite session store and rejects the CE LoginSource and RunSourceQuery operations. The underlying SQLite filesystem primitive is in the shared connector, so the remediation is applied there for both editions.
Summary
A network attacker with no pre-existing credentials can log in to CE's built-in sample SQLite database, use user-supplied SQLite SQL to attach the CE session store at /data/whodb.db, and copy an active victim session's encrypted source credentials into an attacker-controlled session row. CE then accepts the attacker's chosen session and CSRF tokens, decrypts the copied credentials, and executes source queries with the victim session's database authority.
The attacker does not recover the session encryption key or necessarily receive the victim's plaintext credentials. The demonstrated impact is impersonation of active CE source sessions and use of their backend database authority through WhoDB.
At least one active CE source session must exist for a backend pivot. The attack reaches backends represented by active CE session rows; it does not establish access to every saved or inactive connection.
Root cause
The exploit combines three independent trust failures:
- The built-in sample database is intentionally available without external credentials, but a successful sample login receives the same CE session privileges as an ordinary source login.
- SQLite database path validation runs only when the primary connection is opened.
ATTACH DATABASEin later user-supplied SQL can open another SQLite file by absolute path and bypass that validation. - CE encrypted source credentials were authenticated by AES-GCM but were not bound to the session-token or CSRF-token hashes. A valid encrypted credential blob could therefore be copied into a row containing attacker-computable hashes.
The CE session store is a SQLite file at /data/whodb.db. Session and CSRF values are stored as unsalted SHA-256 hashes, while source credentials are stored as AES-256-GCM ciphertext. Knowing the encryption key is unnecessary because CE decrypts the copied ciphertext during normal session lookup.
Reproduction
The following sequence was verified end to end against the exact 0.122.0 image digest above:
- A legitimate victim logged in to a PostgreSQL 16 source, creating an active CE session.
- A separate unauthenticated client called
LoginSourcewith source typeSqlite3and databasewhodb-sample. The operation returnedStatus: trueand issuedwhodb_ce_sessionandwhodb_csrfcookies. - Using that sample session, the attacker executed:
``sql ATTACH DATABASE '/data/whodb.db' AS store ``
- The attacker read an active victim's
encrypted_credentialsfromstore.sessionsand inserted a new row containing:
session_hash = SHA-256(attacker_chosen_session_token)- the victim's encrypted credential blob
csrf_token_hash = SHA-256(attacker_chosen_csrf_token)- a future expiry
- A request carrying the attacker-chosen cookies was accepted.
RunSourceQueryreached a separate PostgreSQL container and returned:
``text current_database = q79w_victim current_user = q79w_victim marker = q79w-confirmed-marker ``
This confirms that CE decrypted the copied PostgreSQL credentials and routed the query through the PostgreSQL connector. The same session lookup and connector dispatch are source-type independent, subject to the privileges and operations supported by the victim source.
The reporter also confirmed that deleting rows from store.sessions invalidates CE sessions and that VACUUM INTO can create a SQLite file at an attacker-selected writable path. Extension loading and the SQLite CLI-only readfile() function were not available in the tested image; no RCE or direct encryption-key read was demonstrated.
Impact
Confidentiality: High. An attacker can use an active victim session's source credentials through WhoDB and read data allowed by that source account.
Integrity: High. The attacker can modify the CE session store and can submit mutating source queries with the victim account's database privileges.
Availability: High. The session store can be modified to invalidate active CE sessions. Victim source privileges may also permit destructive or availability-impacting backend operations.
Scope: Changed. WhoDB is the vulnerable component, while independently managed backend databases are impacted using their own access-control authority.
CVSS v3.1: AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H (10.0 Critical). The active-victim-session prerequisite should be considered when applying an environment-specific score.
Remediation
The pending fix uses SQLite and session-store security boundaries rather than SQL string matching:
- All server-mode user-source SQLite connections use a dedicated
go-sqlite3driver with a per-connection authorizer that deniesSQLITE_ATTACHandSQLITE_DETACH. Installing it inConnectHookensures every physical pooled connection is protected. This shared connector change applies to CE and EE. - The sample database is seeded through a private writable connection. Connections returned to users are SQLite
query_onlyconnections, and attempts to disablequery_onlyare denied. - CE encrypts a versioned session envelope containing the session hash, CSRF hash, and source credentials. Lookup verifies both embedded hashes after authenticated decryption. Copying ciphertext to another session row therefore fails closed.
- Legacy unbound CE session ciphertext is rejected, forcing affected CE users to log in again after upgrade.
SQLITE_DBCONFIG_DEFENSIVE is not a sufficient fix because it does not disable ATTACH DATABASE. HMACing only the token hash is also insufficient because an attacker with session-store write access can retain a valid attacker session row and replace only its encrypted credential blob.
Running the container as a non-root user is recommended defense in depth, but it does not by itself separate the session store from user-supplied SQLite running in the same process.
Validation
Regression coverage verifies that:
- literal and bound-parameter
ATTACH DATABASEstatements are rejected; VACUUM INTOcannot create an output file;- the sample database remains readable but rejects writes and attempts to disable
query_only; - copied CE session ciphertext is rejected while the victim session remains valid;
- legacy unbound CE session rows are rejected; and
- EE's authenticated SQLite execution path receives the same attachment denial.
CE and EE backend builds and focused tests pass with the pending fix.
Timeline
- 2026-07-15: CE encrypted SQLite session storage introduced;
0.121.0is the first containing release. - 2026-07-30: Reporter identified the sample-database and SQLite filesystem primitives and reproduced CE session forgery.
- 2026-07-31: Reporter verified a forged CE session against a separate PostgreSQL 16 backend.
- 2026-09-29: Maintainer independently reproduced the complete chain against the reported
0.122.0image digest, confirmed current CE exposure, clarified EE scope, and prepared the shared-connector and CE session-binding remediation.