Description
execute_query records the first 100 characters of every statement as a tracing span field, and the file log layer writes JSON at DEBUG level. Statements that carry credentials therefore land in plain text in the log directory. The admin dialogs build exactly these statements: CREATE USER … IDENTIFIED BY '<password>' and ALTER USER … IDENTIFIED BY ….
Reproduce
The span field is in src-tauri/src/commands/mod.rs:232:
#[tracing::instrument(skip(state), fields(connection_id = %connection_id, sql_preview = %sql.chars().take(100).collect::<String>()))]
pub async fn execute_query(The file layer is in src-tauri/src/lib.rs around line 395: tracing_appender::rolling::daily(&log_dir, "sqlpilot.log"), with .json() and EnvFilter::new("debug,…").
The callers are src/components/admin/CreateUserDialog.tsx:84 and src/components/admin/ChangePasswordDialog.tsx:38. Both run through runStatement → execute_query. A typical CREATE USER 'app'@'%' IDENTIFIED BY 'secret' is well under 100 characters, so the whole password is captured.
To confirm at runtime: create a user from the admin panel, then grep IDENTIFIED the newest sqlpilot.log* in the app's log directory.
Cause
Query history already redacts credentials. The tracing field bypasses that redaction. The daily log files also have no retention limit, so captured statements accumulate.
Fix
- Redact the preview before it is recorded. Reuse the history redaction (
src/lib/sql-redact.tsholds the frontend version; the Rust history code has its own), or dropsql_previewand log only the length and statement kind. - Apply the same treatment to
explain_queryand any otherinstrumentthat recordssql. - Cap log retention, for example with
tracing_appender::rolling::Builder::max_log_files. - Add a unit test asserting that
IDENTIFIED BY '…'never reaches a span field.
Activity
fix: keep credentials out of the log file
fix: credentials, CSP and CI gaps from the docs review (#880)