Skip to content

Never let a password field's dictation linger on the clipboard or in Recent (#348, #349) - #378

Merged
alexkroman merged 13 commits into
mainfrom
fix/secure-dictations-never-linger
Nov 25, 2026
Merged

alexkroman merged 13 commits into
mainfrom
fix/secure-dictations-never-linger

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

Fixes #348. Fixes #349.

Both issues are the same promise ("anything dictated into a password field is never kept"), broken on two different paths.

#348 (Mac): a quiet "Copied" left the password as an ordinary clipboard string

The session knew the target was secure (targetIsSecure) and kept it out of Recent, but the injector never learned it. When the paste degraded (noEditableTarget, targetAppLost, or the keystroke couldn't be built), KeyInjector called the unmarked clipboard.write, and Maccy/Raycast/Alfred archived the secret.

  • InjectorProtocol.insert gains secure:. The session passes capturedContext?.targetIsSecure == true; replaceSelection, typeText, and insertAtFocus pass false.
  • ClipboardAccess.write / writeAndPrepareRestore take concealed:. For a secure paste, SystemClipboard:
    • marks every write with org.nspasteboard.ConcealedType + TransientType;
    • keeps it off Universal Clipboard (prepareForNewContents(with: .currentHostOnly));
    • clears a leave-behind after concealedLifetime (90 s), unless something newer was copied (change-count guard).
  • The restore after a successful secure paste puts the user's own contents back unconcealed, as before.

#349 (iPhone): isSecure was never set, so every iOS dictation entered Recent / stt_prompt

  • On a press, the keyboard checks isSecureTextEntry and a .password / .newPassword textContentType. iOS gives true secure-entry fields to the system keyboard, so the content type is the case a third-party keyboard actually sees.
  • A secure press sends no priorText / selectedText and sets the new KeyboardCommand.isSecure. The coordinator passes it into FocusedFieldContext(isSecure:), so the engine's existing gate fires.
  • KeyboardRelayInjector's clipboard fallback for a secure result uses UIPasteboard.setItems(_:options:) with .localOnly and a 90 s .expirationDate.

Tests

  • Engine: KeyInjectorSecureTests (all three degraded paths leave concealed words; the secure paste is concealed until restored). SystemClipboardTests covers the markers, the unconcealed restore, and the expiry's change-count guard. DictationSessionContextTests asserts the session forwards secure (including the late-context-read case).
  • iPhone:
    • a password-field press carries no text and isSecure == true;
    • an ordinary press is unchanged;
    • a coordinator dictation into a password field is inserted but never joins Recent;
    • the clipboard fallback test now runs with both secure values.
  • Locally: swift test suites green; scripts/ios-test.sh green, 368 tests, BlurtiOSCore coverage 96.11%.

Docs: README Privacy and the engine README's InjectorProtocol section are updated.

🤖 Generated with Claude Code

alexkroman-assembly and others added 4 commits November 24, 2026 14:38
…Recent (#348, #349)

Mac (#348): the session knew a dictation went into a password field
(targetIsSecure) and kept it out of Recent, but the injector never
learned it. A paste that degraded to the quiet "Copied" left the secret
as an ordinary, unmarked clipboard string, which Maccy/Raycast/Alfred
archive. InjectorProtocol.insert now takes `secure`; for a secure paste
every SystemClipboard write carries ConcealedType + TransientType, is
kept off Universal Clipboard (currentHostOnly), and a leave-behind is
cleared after 90 s unless something newer was copied.

iPhone (#349): the keyboard never read whether its field was a password
field, so every iOS dictation had targetIsSecure == false and the
engine's refuse-to-remember gate never fired. A press now checks
isSecureTextEntry and a .password/.newPassword content type, withholds
the field's text, and sends isSecure; the coordinator passes it into
FocusedFieldContext. The relay's clipboard fallback for a secure result
is local-only and expires after 90 s.

Fixes #348
Fixes #349

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…copy

Fixes #341.

- ⌘V and ⌘C were posted on hardcoded kVK_ANSI_V/kVK_ANSI_C. macOS matches a
  ⌘ shortcut by character, so on Dvorak every paste was ⌘K (and the restore
  then took the words back), and on Turkish-F the read-aloud copy fallback
  pasted. Both are now resolved on the current ASCII-capable layout with ⌘
  held (KeyboardLayout, moved to Injection/), falling back to the US key.
  Voice-command chords read the layout with ⌘ held too when they hold it.
- KeyInjector (write, ⌘V, settle, restore) and SelectionCopy (snapshot, ⌘C,
  poll, restore) now take turns on the pasteboard through a FIFO
  PasteboardLock, so a copy can't keep a settling paste's transcript as the
  user's clipboard and a paste's restore can't land under a copy's poll.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1VN3Xe9T3rmTwrjDLC
Making postPaste async put a main-actor layout read between the final
Task.checkCancellation() and the ⌘V, so a cancel landing there no longer
stopped the paste. The key is now read through its own seam
(resolvePasteKey) ahead of the gate, and postPaste is synchronous again,
taking the key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1VN3Xe9T3rmTwrjDLC
… relay copy test

Keeps KeyInjectorInsertTests under the type-body-length limit, folds the
secure relay case into the existing clipboard-fallback test as an
argument (jscpd), and drops an implicitly unwrapped optional from
FakeProxy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
alexkroman-assembly and others added 2 commits November 24, 2026 16:01
# Conflicts:
#	Sources/BlurtEngine/Injection/KeyInjector.swift
#	Sources/BlurtEngine/Injection/SystemClipboard.swift
Matches KeyInjector.insert's default, so a test calling the relay directly
describes an ordinary field without restating it (and #361's new relay
test keeps compiling once this lands).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alexkroman
alexkroman removed this pull request from the merge queue due to a manual request Nov 25, 2026
@alexkroman
alexkroman added this pull request to the merge queue Nov 25, 2026
# Conflicts:
#	Sources/BlurtEngine/Injection/KeyInjector.swift
#	Sources/BlurtEngine/Injection/SystemClipboard.swift
@alexkroman
alexkroman removed this pull request from the merge queue due to a manual request Nov 25, 2026
@alexkroman
alexkroman enabled auto-merge November 25, 2026 00:31
…-behinds (#378) and unknown-security fields (#358)

Both PRs reword the same sentence; carrying the identical combined
paragraph in each lets them merge in either order without a conflict.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
alexkroman pushed a commit that referenced this pull request Nov 25, 2026
…-behinds (#378) and unknown-security fields (#358)

Both PRs reword the same sentence; carrying the identical combined
paragraph in each lets them merge in either order without a conflict.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	App/BlurtiOS/BlurtiOS/Sources/DictationCoordinator+Commands.swift
#	App/BlurtiOS/BlurtiOSCore/KeyboardModel+Handshake.swift
#	App/BlurtiOS/BlurtiOSCore/SharedState.swift
#	App/BlurtiOS/BlurtiOSTests/DictationCoordinatorTests+Dictation.swift
#	App/BlurtiOS/BlurtiOSTests/DictationCoordinatorTests.swift
#	App/BlurtiOS/BlurtiOSTests/ProtocolTests.swift
alexkroman pushed a commit that referenced this pull request Nov 25, 2026
#378 adds its own test at the same spot; apart, the two merge in either
order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alexkroman
alexkroman added this pull request to the merge queue Nov 25, 2026
@alexkroman
alexkroman removed this pull request from the merge queue due to a manual request Nov 25, 2026
@alexkroman
alexkroman added this pull request to the merge queue Nov 25, 2026
alexkroman-assembly and others added 4 commits November 24, 2026 17:33
#377 added a clipboard test calling writeAndPrepareRestore without the
concealed: argument this PR adds, and with its own copy of the
ConcealedType constant (now SystemClipboard's). The concealed-write and
password-field-press tests move into same-file extensions, so the combined
SystemClipboardTests and KeyboardModelGateTests bodies stay within
type_body_length.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#365 and this PR each grow the file; together they reached 401. One
comment reflowed (within the 120-column limit), no code change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alexkroman
alexkroman removed this pull request from the merge queue due to a manual request Nov 25, 2026
@alexkroman
alexkroman added this pull request to the merge queue Nov 25, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to invalid changes in the merge commit Nov 25, 2026
@alexkroman
alexkroman enabled auto-merge November 25, 2026 01:44
alexkroman pushed a commit that referenced this pull request Nov 25, 2026
With main, the suite's struct body reached 253 lines (type_body_length
250). The suite already splits by topic (+Latch, +Undo); the stepped retry
and deadline get their own file, which keeps this PR clear of the gate
tests #378 also moves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alexkroman
alexkroman added this pull request to the merge queue Nov 25, 2026
Merged via the queue into main with commit 3b24d1b Nov 25, 2026
13 checks passed
@alexkroman
alexkroman deleted the fix/secure-dictations-never-linger branch November 25, 2026 02:51
alexkroman pushed a commit that referenced this pull request Nov 25, 2026
… CI run

Recent multi-commit PRs (#410, #413, #414, #416, #420, #422, #423, #425, #426)
mostly spent their extra ~37-minute runs on things nothing caught before CI:

- scripts/check-swift-lint-lite.sh: a toolchain-free text match for the opt-in
  SwiftLint/swift-format rules it can see (modifier_order, no_empty_block,
  NoBlockComments, swift-format's `catch  where`). Run by check.sh (so
  --portable and --lint-only) and the swift-budgets edit hook; would have
  flagged the pre-fix files of #414, #422 and #425.
- .claude/hooks/push-gate.sh: a PreToolUse hook that runs
  `check.sh --portable` (~20 s) before any `git push` and blocks a red one —
  jscpd clones (#420, #422) and post-merge size overruns (#363, #378) were
  pushes that skipped the documented portable run.
- AGENTS.md / CLAUDE.md: a "Rules only CI catches" list for the rest
  (variable_shadowing, one_declaration_per_file, type_contents_order,
  multiline_function_chains, MemberImportVisibility, one argument per line),
  and the new hook and script in the hooks table and permissions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1UDUZXyuF6g7GUmmNu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants