Repository navigation
feat(history): never write a password to history - #593
Merged
Merged
Conversation
EVWorth
force-pushed
the
fix/history-redact-credentials
branch
from
September 9, 2026 22:53
2401a8d to
88112ac
Compare
This was referenced Sep 9, 2026
`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
force-pushed
the
fix/history-redact-credentials
branch
from
September 9, 2026 23:58
88112ac to
008b6cc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #587. First of the history hardening pass.
CREATE USER 'x'@'%' IDENTIFIED BY 's3cret'was stored verbatim inlocalStorage. 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
redactCredentialsworks 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, itsPASSWORDand plugin (WITH … BY/AS) forms,SET PASSWORDin both spellings,MASTER_PASSWORD/SOURCE_PASSWORD,CREATE SERVERoptions.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
UPDATE users SET password = 'x'is redacted too.SET password =andSET 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.