Repository navigation
Route every pasteboard write through one primitive - #424
Merged
Merged
Conversation
SystemClipboard's rule for a secret — kept off Universal Clipboard, marked ConcealedType and TransientType, and cleared after concealedLifetime — was applied at each call site, and each security fix since found a site it had missed: the expiry was added to write, then to the unreadable-clipboard paste, then to the restore of a concealed snapshot, whose host-only scope was also copied in by hand. Every write (the paste, the leave-behind, both restores, the expiry's clear) now goes through one private put(_:transient:concealed:expiry:), which counts the write as Blurt's own, prepares the pasteboard host-only when concealed, writes the text or items, adds the markers and, when concealed, schedules the expiry. The one concealed write that is not expired, a paste whose snapshot its restore will put back, says so with an explicit .leftToRestore. setString is gone; tests write with write(_:concealed: false), which was the same call. Production behaviour is unchanged. Differences only a direct caller of restore(_:) or an unreachable path can see: restore(_:) now schedules a concealed snapshot's expiry itself rather than leaving it to restore(_:ifChangeCountIs:), its only production caller; a restore that writes nothing no longer bumps the own-write count; a refused batch with no text floor schedules no expiry over the pasteboard it left empty; and the transient marker on a rebuilt item now follows its text floor. A new test pins the invariant: every concealed write path is counted, marked and given exactly one expiry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1Vp9Andd7LBEDhGKeC
alexkroman
pushed a commit
that referenced
this pull request
Nov 25, 2026
No content conflicts: #398 moved AssemblyAIAccount.swift into BlurtAssemblyAI, and git carried this PR's comment at the early return along with it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1Vp9Andd7LBEDhGKeC
alexkroman
pushed a commit
that referenced
this pull request
Nov 25, 2026
One conflict, in DictationSession+Pipeline.swift: #398 renamed the too-short check's error to the provider-neutral TranscriberError on the line this PR made log against its own press. Kept both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DS5B1Vp9Andd7LBEDhGKeC
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.
What & why
SystemClipboardapplied its rule for a secret separately in each place that writes the pasteboard. The rule is: keep it off Universal Clipboard, mark itConcealedType/TransientType, and clear it afterconcealedLifetime. Each security fix since then found a write path the rule had missed:write.restore(_:ifChangeCountIs:)and copied the host-onlyprepareForNewContentsintorestore(_:)by hand.Every write now goes through one private
put(_:transient:concealed:expiry:). That covers the paste, the leave-behind, both restores, the text floor and the expiry's own clear. In order, it:ownWritesbefore it lands,.text,.itemsor.nothing,expireOurWrite().It returns false when
writeObjectsrefuses the batch, so the restore still falls through to the plain-string floor (#347). The one concealed write that gets no expiry is a paste whose snapshot its restore will put back. That exception is now an explicitConcealedExpiry.leftToRestoreargument rather than a missing call, and its behaviour is unchanged.setStringis removed; tests callwrite(_:concealed: false), which was the same call. ARCHITECTURE.md's paste-restore paragraph describes the primitive.Behaviour change: none in production. A direct caller of
restore(_:)(only tests) or an unreachable path could see these differences:restore(_:)now schedules a concealed snapshot's expiry itself, instead of leaving that torestore(_:ifChangeCountIs:), its only production caller. The change count it keys on is the same.writeObjectsrefuses a concealed batch and there is no text floor, no expiry is scheduled. The pasteboard is already empty, so the old expiry only cleared an empty pasteboard again.How it was tested
Written in a Linux sandbox with no Swift toolchain:
scripts/check.sh --portablepasses, as docheck-swift-size.sh(SystemClipboard.swiftis at 289 lines) andcheck-test-clock.sh. CI on macOS verifies the build, all tests, swiftlint, swift-format and periphery.New
everyConcealedWriteExpires(inSystemClipboardTests+Expiry.swift, an extension of the serialized suite) runs every concealed write path. It checks that each one bumpsownWriteCount, leaves the secret markedConcealedTypeandTransientType, and schedules exactly one expiry, which then clears it.restore(_:),restore(_:ifChangeCountIs:), and a restore whose string comes from the text floor.putalone enforces it.restorablePasteSchedulesNothingstill pins the restorable concealed paste.scripts/check.shpasses (or CI will, if I'm not on a Mac)I read AGENTS.md and this doesn't reintroduce anything
deliberately removed
Docs updated if behavior changed
Generated by Claude Code