Skip to content

Conceal password dictations on the clipboard so managers don't archive them - #350

Closed
alexkroman wants to merge 7 commits into
mainfrom
fix/348-conceal-secure-clipboard
Closed

alexkroman wants to merge 7 commits into
mainfrom
fix/348-conceal-secure-clipboard

Conversation

@alexkroman

@alexkroman alexkroman commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #348

Problem

A dictation into a secure field that degraded to the quiet Copied notice (targetAppLost / noEditableTarget) was written to NSPasteboard.general as a plain string — no TransientType, no ConcealedType — so clipboard managers (Maccy, Raycast, Alfred) archived the secret. The session already withheld secure dictations from Recent / stt_prompt, but InjectorProtocol.insert never received targetIsSecure.

Fix

  • InjectorProtocol.insert gains targetIsSecure:; DictationSession.inject passes capturedContext?.targetIsSecure == true (the same value that gates the Recent ring). replaceSelection / insertAtFocus pass false — no field was read for them.

  • KeyInjector.performInsert threads it to all three clipboard writes (activation failed, no editable target, the paste itself).

  • ClipboardAccess.write / writeAndPrepareRestore take concealed:; SystemClipboard adds org.nspasteboard.ConcealedType and TransientType for secure writes (some managers record Concealed-only items and merely hide them).

  • Ordinary quiet-Copied writes are unchanged: unmarked, so a manager may keep them for hand-paste.

  • iPhone's KeyboardRelayInjector ignores the flag — iOS never hands a secure field to a third-party keyboard.

  • Secure writes also match 1Password's handling of a copied password: prepareForNewContents(with: .currentHostOnly) keeps them off Universal Clipboard (which ignores the nspasteboard markers), and they're cleared after 90 s (SystemClipboard.concealedLifetime, 1Password's default) unless something has written to the pasteboard since — the same change-count guard as the paste's restore, so a newer user copy survives and the normal paste path (restored at 400 ms) is unaffected.

Tests

  • SystemClipboardTests.concealedWriteExpires / concealedExpirySparesNewerCopy — the 90 s clear (shortened in tests) fires, and spares a newer copy.
  • SystemClipboardTests.concealedWriteIsMarked — secure write carries both markers; writeOverwrites now also asserts no ConcealedType.
  • KeyInjectorFallbackTests.secureFallbackIsConcealed (both quiet paths) and securePasteIsConcealed.
  • DictationSessionContextTests — secure field reaches the injector flagged; ordinary field doesn't.

🤖 Generated with Claude Code

alexkroman-assembly and others added 2 commits November 24, 2026 11:37
…e them (#348)

A dictation into a secure field that degraded to the quiet "Copied" path was
left on NSPasteboard as an unmarked string, so Maccy/Raycast/Alfred kept the
secret. The session already withheld it from Recent via targetIsSecure, but
the injector never received the flag.

InjectorProtocol.insert now takes targetIsSecure; KeyInjector passes it to
every clipboard write, and SystemClipboard marks secure writes with
org.nspasteboard.ConcealedType plus TransientType. Ordinary quiet "Copied"
writes stay unmarked for hand-paste, as before.

Fixes #348

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

Match 1Password's handling of a copied password: a secure dictation's
clipboard write is current-host-only (Universal Clipboard ignores the
nspasteboard markers) and cleared after 90 seconds, unless something else
has written to the pasteboard since — the same change-count guard the
paste's restore uses, so a newer user copy survives.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
alexkroman and others added 2 commits November 24, 2026 11:43
The release path reads targetIsSecure from the press-time AX read, but a
read still blocked when the transcript came back answered nil — read as
"not a password field". A target slow enough to outlast recording plus
transcription could get a password remembered into Recent / stt_prompt,
left unconcealed on the clipboard, and written to the developer-mode log.

PressContext now records whether the read has settled, and
capturedContext fails closed: an unsettled read answers a context flagged
secure. That dictation is still transcribed and pasted; it just isn't
remembered, logged, or left unconcealed.

Co-authored-by: Alex Kroman <alex@assemblyai.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…th limit

The fail-closed read (#352) pushed DictationSession.swift to 407 lines and
DictationSessionContextTests.swift to 431, failing swiftlint's
file_length on CI.

The rule moves to PressContext.releaseContext, beside the settled flag
and value it reads; capturedContext now delegates to it. The
self-contained failure-logging suite moves to its own file. No
behavior change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alexkroman
alexkroman added this pull request to the merge queue Nov 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 24, 2026
Resolves FakeClipboard (both sides added a flag: concealed from this
branch, keptForHandPaste from #351 — both kept). #351's new fallback
when the ⌘V keystroke can't be built calls `write`, which here takes
`concealed:`; it passes `secure` like the other two "copied" paths, so
a password left for hand-paste stays concealed. New test covers it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SelectionSpeechRouterTests' tap-read test timed out on CI: with the whole
suite starting at once, the main actor was contended for ~5 s, and the poll
resumed past its 5 s deadline before the router's queued tasks had run.
The budget only bounds a genuine hang, so it can afford to be generous.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1ScLg3wRbaz6sT9vSP
The poll and the work it waits on share the main actor. On CI that actor
was contended for ~5 s as the whole suite started, so a wall-clock deadline
elapsed with neither side running, and SelectionSpeechRouter's tap-read
test woke past it and failed before the router's queued tasks had run. A
stall delays a poll as much as the work, so counting polls makes the
budget immune to it, while a genuine hang still fails after at least the
timeout. Replaces the earlier 30 s bump, which only narrowed the window.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1ScLg3wRbaz6sT9vSP
@alexkroman
alexkroman added this pull request to the merge queue Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

CI status on 56ffdf1:

  • check passes. The earlier red was SelectionSpeechRouterTests' tap-read test timing out in waitUntil. The poll and the work it waits on share the main actor, which CI's suite-wide startup contended for ~5 s, so a wall-clock deadline expired with neither side running. waitUntil now counts its budget in polls (Tests/BlurtEngineTests/Stubs/WaitUntil.swift), so a stall costs nothing and a real hang still fails after ≥ 5 s.
  • gate fails only on ios-build: cancelled. The job hit its 30-minute timeout-minutes during swiftlint analyze, after the iPhone tests and coverage gate (96.1%) had passed. This isn't this PR's: of the last 7 check.yml runs on main, ios-build passed twice (~29 min each) and was cancelled the other five, three of them at the 30-minute limit. Proposed fix: raise ios-build's timeout-minutes (e.g. to 45) in .github/workflows/check.yml, separately or here, the author's call.

Generated by Claude Code

@alexkroman
alexkroman removed this pull request from the merge queue due to a manual request Nov 24, 2026
@alexkroman

Copy link
Copy Markdown
Collaborator Author

Superseded by #378, which lands the same #348 fix (secure flag on insert; ConcealedType + TransientType, currentHostOnly, 90 s expiry) together with #349, the iPhone half.

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.

Password dictations that quiet-“Copied” land in clipboard history — inject never sees targetIsSecure

3 participants