Skip to content

fix: debug log file records SQL text, including passwords #875

Closed

Description

@EVWorth

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.ts holds the frontend version; the Rust history code has its own), or drop sql_preview and log only the length and statement kind.
  • Apply the same treatment to explain_query and any other instrument that records sql.
  • 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

  1. added
    bug
    on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions