Skip to content

feat(history): never write a password to history - #593

Merged
EVWorth merged 1 commit into
mainfrom
fix/history-redact-credentials
Sep 10, 2026
Merged

EVWorth merged 1 commit into
mainfrom
fix/history-redact-credentials

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 9, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #584. This branch is cut from fix/history-structured-errors, so it carries those two commits as well — the redaction change edits the same addEntry and HistoryEntry that #584 touches, and rebasing onto main would just move the conflict. Review #584 first; the commit to read here is the last one.

Closes #587. First of the history hardening pass.

CREATE USER 'x'@'%' IDENTIFIED BY 's3cret' was stored verbatim in localStorage. The app is careful with passwords everywhere else — OS keyring, #[serde(skip_serializing)] on the profile fields so they never cross IPC — and a statement carrying one in its text walked past all of it.

Most competing clients store these as typed. Treating this as a place to be better rather than to match, so redaction is not a preference: it happens on the way into storage and the plaintext is never written.

Approach

redactCredentials works from the keyword to the literal, not by matching whole statements. A statement shape nobody anticipated can't smuggle a password past by putting it somewhere a single regex didn't look.

Covered: IDENTIFIED BY, its PASSWORD and plugin (WITH … BY / AS) forms, SET PASSWORD in both spellings, MASTER_PASSWORD/SOURCE_PASSWORD, CREATE SERVER options.

The literal scanner handles backslash and doubled-quote escapes, double-quoted literals, backtick identifiers containing quotes, and comments. A password with a quote in it is exactly what a naive scan cuts short and half-stores.

It runs in addEntry, not at call sites — that's the one door into storage, and this must not depend on every future caller remembering. The driver's error message gets the same treatment since it can quote the statement back.

Two deliberate choices

  • The redacted form doesn't run. A plausible placeholder would be worse: re-running would quietly set the password to the placeholder. The panel marks such entries so the user knows why.
  • UPDATE users SET password = 'x' is redacted too. SET password = and SET PASSWORD = aren't distinguishable by keyword. Over-redacting a column write costs nothing; under-redacting a credential costs the password. Recorded as a test so it reads as a decision, not an accident.

Verification

28 tests on the redactor, 4 on the store. Both store tests fail against the unredacted store. Full suite 1842 passing.

`CREATE USER 'x'@'%' IDENTIFIED BY 's3cret'` was stored verbatim. The app
is careful with passwords everywhere else — they live in the OS keyring,
and the profile fields holding them are #[serde(skip_serializing)] so they
never cross the IPC boundary — and a statement carrying one in its text
walked past all of it (#587).

Most competing clients store these as typed. This is a place to be better
rather than to match, so redaction is not a preference: it happens on the
way into storage and the plaintext is never written at all.

`redactCredentials` works from the keyword to the literal rather than
matching whole statements, so a statement shape nobody anticipated cannot
smuggle a password past by putting it somewhere a single regex did not
look. It covers IDENTIFIED BY, its PASSWORD and plugin forms, SET PASSWORD
in both spellings, replication passwords under both the MASTER_ and
SOURCE_ names, and CREATE SERVER options. The literal scan handles
backslash and doubled-quote escapes, double-quoted literals, backtick
identifiers containing quotes, and comments — a password with a quote in
it is exactly the case a naive scan would cut short and half-store.

It runs in `addEntry` rather than at the call sites, because that is the
one door into storage and a password must not depend on every future
caller remembering. The driver's error message gets the same treatment,
since it can quote the statement back.

The redacted form is deliberately not runnable: a plausible placeholder
would be worse, because re-running the entry would quietly set the
password to the placeholder. The panel marks such entries so the user
knows why.

One deliberate over-reach, recorded in the tests: `UPDATE users SET
password = 'x'` is redacted too. `SET password =` and `SET PASSWORD =` are
not distinguishable by keyword, and over-redacting a column write costs
nothing next to under-redacting a credential.

Closes #587

Co-Authored-By: Claude Opus 5 <[email protected]>
@EVWorth
EVWorth force-pushed the fix/history-redact-credentials branch from 88112ac to 008b6cc Compare September 9, 2026 23:58
@EVWorth
EVWorth merged commit d38f4bf into main Sep 10, 2026
11 checks passed
@EVWorth
EVWorth deleted the fix/history-redact-credentials branch September 10, 2026 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P0/security] Statements carrying credentials are stored in history verbatim

1 participant