Skip to content

Treat a field read still blocked at release as a secure field - #352

Merged
alexkroman merged 1 commit into
fix/348-conceal-secure-clipboardfrom
fix/secure-flag-unresolved-read
Nov 24, 2026
Merged

alexkroman merged 1 commit into
fix/348-conceal-secure-clipboardfrom
fix/secure-flag-unresolved-read

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

Stacked on #350 (it fixes the clipboard half through #350's targetIsSecure plumbing). Merge #350 first; GitHub will retarget this to main.

Problem

Every release-side privacy decision reads targetIsSecure from capturedContext, i.e. PressContext.resolved. That's nil in two different situations: the read finished and found nothing worth carrying, or the read is still blocked (FocusCapture makes ~6 serial AX round trips, each capped at ~1 s, against a slow or beachballing frontmost app). Both were read as "not a password field". So a target slow enough to outlast recording + transcription would get a password:

Raised in the code review on #350 as a bug that predates it.

Fix — fail closed rather than wait

  • PressContext records isSettled separately from resolved.
  • DictationSession.capturedContext returns unsettledContext, a context flagged targetIsSecure: true, while the read is still blocked. All three readers (the Recent gate, inject, the log) pick it up from one place.
  • Not a wait: by release the read has had the whole recording plus transcription, so only a genuinely hung target reaches this, and making the paste wait on it would add latency for no gain. The cost of failing closed is limited to that one dictation: still transcribed and pasted, just not remembered, logged, or left unconcealed (it's cleared after 90 s per Conceal password dictations on the clipboard so managers don't archive them #350).

Tests

  • New unsettledReadFailsClosed: a read that never lands → pasted, flagged secure to the injector, not in Recent, logged with the secure context.
  • timedOutReadStillSendsPressKnownContext now lets the first press's read land before release, so it has history to seed (a stalled first dictation is correctly no longer remembered).
  • Full swift test: 1309 tests pass.

🤖 Generated with Claude Code

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: Claude Opus 5.5 <noreply@anthropic.com>
@alexkroman
alexkroman merged commit b118384 into fix/348-conceal-secure-clipboard Nov 24, 2026
1 check passed
@alexkroman
alexkroman deleted the fix/secure-flag-unresolved-read branch November 24, 2026 19:43
@alexkroman
alexkroman restored the fix/secure-flag-unresolved-read branch November 24, 2026 19:55
alexkroman pushed a commit that referenced this pull request Nov 24, 2026
…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>
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.

2 participants