Repository navigation
Conversation
fdussert
left a comment
There was a problem hiding this comment.
Thanks a lot for this, Livio — the provider itself is carefully written: constant SQL, -readonly + query_only, a timeout, a row cap and a time window. It fails closed, the code goes through pbcopy's stdin rather than argv, errors are generic, nothing is logged, and paired devices are refused. That's the hard part done well. Before it can land in core, though, the threat model needs a few changes:
1. The channel should be built-in only. Right now any registry widget that lists messages-2fa in commands can call copyLatest whenever it likes; nothing ties the call to a real tap, and the consent dialog only says "controls messages-2fa". That widget can't read the code (clipboard is built-in only and the frame has no clipboard permission), but it can push a fresh OTP onto the pasteboard at a moment of its choosing, overwrite whatever the user just copied in a loop, and learn from ok vs "no code" that a sign-in is happening. Once the code is on the pasteboard, Universal Clipboard, cloud-synced clipboard managers and Fremkit's own clipboard widget all read it. Please add messages-2fa to BUILTIN_ONLY_CHANNELS. That means the widget ships in widgets/ rather than on the registry.
2. It needs its own opt-in. Full Disk Access may already be granted for the disk map, and with this PR that grant silently enables reading Messages. SECURITY.md currently says FDA only benefits the disk map. Please gate the command on a privacy setting that is off by default (like claudeAccountUsage), explain the FDA scope next to it, and update SECURITY.md. That includes the "same-user process is out of scope" paragraph: a process without FDA could now get Messages codes through Fremkit.
3. Mark the pasteboard write as concealed and transient. A bare pbcopy makes the OTP an ordinary entry. Fremkit's clipboard history records it unmasked (6 digits is under the secret heuristic's length) and shows it on the Edge and on a paired device whose screen holds that widget. Suggestion: a constant /usr/bin/osascript -l JavaScript script that reads the code from stdin, so it never appears on argv, and that:
- declares
org.nspasteboard.ConcealedTypeandTransientType; - uses
currentHostOnlyso the code doesn't go to other devices; - clears the pasteboard after ~60 s if
changeCounthasn't moved.
4. Extraction picks up numbers that aren't OTPs. With a synthetic fake runner:
- "a sign-in to the account ending 4821 … Your code: 739201" copies
4821; - "New login on 19/10/2026 … Verification code 482913" copies
2026; - a friend's "le digicode c'est 4821, et le login wifi…" copies
4821; - "Votre code de connexion / de sécurité est 482913" copies nothing.
Ideas:
- prefer the number closest to "code" / "is your", or the one right after it;
- skip numbers after "ending" and date-shaped runs;
- exclude group chats, and ideally contacts;
- add French keywords (connexion, sécurité, accès, confirmation).
5. Housekeeping:
- Please rebase onto current
main(0.5.0).app.tsconflicts; providers are now registered inregisterRealProviders(), and demo mode needs a fake that answers without touching the Mac. CommandContextnow requirespaired, sopnpm typecheckfails on the test file.- A rate limit on
copyLatestwould help, since each call spawnssqlite3. - Please return error codes translated with
tr()instead of English strings the widget has to match. - A CHANGELOG line under Unreleased would be welcome.
- Tested with pnpm: the focused suite passes (9/9), and the full suite passes on the PR's base.
Happy to help with any of these. The core of the work is solid, and this is mostly about who is allowed to pull the trigger.
a66fcb7 to
c496de6
Compare
|
Thanks for the review. The updated candidate is
This PR contains the core provider, not the Sietch widget. Marketplace widgets still cannot invoke a built-in-only command, and the Sietch integration card remains open while a trusted packaging/integration path is resolved. The PR remains a draft; this source-level response does not claim runtime clipboard expiry or end-to-end widget integration is verified. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Follow-up for the clipboard ownership race, fixed in commit The writer now captures the count returned by Validation at this commit: focused Messages 2FA tests 21/21; server suite 134 files, 2,699 passed and 2 skipped; source and test TypeScript checks exit 0; diff check passes. Cleanup uses a separate count comparison and clear call, so this is not an atomic compare-and-clear guarantee. Real macOS/JXA/pasteboard behavior remains UNVERIFIED. |
fdussert
left a comment
There was a problem hiding this comment.
Thanks Livio — this is a big step forward, and the write path is now exactly the shape we hoped for. I replayed 261592f onto current main (only a CHANGELOG conflict with #55; no interaction with the new clipboard masking, which skips concealed entries anyway): pnpm typecheck is clean and pnpm test passes (server 2702 passed / 2 skipped, UI 874). Going through the five points:
1. Built-in only — fixed. messages-2fa is in BUILTIN_ONLY_CHANNELS (server/src/widgets/manifest.ts:185), so install, catalogue and consent all refuse it for a registry package. (Listing it in BUILTIN_ONLY_COMMANDS too is redundant but harmless.) Note for whoever merges: that file is vendored byte for byte in the registry's tools/vendor/widgets/manifest.ts, so it needs re-copying there afterwards.
2. Opt-in — fixed. privacy.messages2FA defaults to false in the schema, the v3 reader and the demo seed, a restore keeps this Mac's privacy, the provider checks it at command time (app.ts:312, messages-2fa.ts:295), and SECURITY.md now covers both FDA and the same-user case. One small gap: the Settings search doesn't know the new label yet — it needs adding to the Privacy entry's labels in ui/src/admin/settingsWindow.ts:77.
3. Concealed/transient write — mostly fixed, with one real bug. The writer is right: a constant script, code on stdin only, CurrentHostOnly, both markers, and the change count captured at write time. I ran WRITE_CODE_SCRIPT against a private named pasteboard (not the general one) on macOS and it produced public.utf8-plain-text + ConcealedType + TransientType and printed the count. The clear scripts don't work as written, though. In JXA a zero-argument Objective-C method is called by property access, so board.clearContents() first clears (via board.clearContents), then tries to call the returned integer and throws TypeError: board.clearContents is not a function (messages-2fa.ts:45 and :116). The pasteboard does get cleared, but only by accident. Every successful cleaner exits non-zero, which fires the exit fallback and a second osascript, and the start-failure path logs a cleanup failure after a clear that actually worked. The unit tests assert the board.clearContents() string (server/test/messages-2fa.test.ts:343,362), which is why nothing caught it. Please:
- use
board.clearContents;in both scripts; - add a macOS-only test (skipped elsewhere) that runs the three scripts against
NSPasteboard.pasteboardWithName(...)with the board injected, thenreleaseGlobally— it's how I checked them, and it would have caught this; - call
/usr/bin/osascriptby absolute path at:51and:62, as the rest of the server now does for system tools.
4. Extraction — partly fixed. The four cases I reported are fixed, and so are the French phrasings and group chats. But the generic markers (your code, code … is/est within 18 characters) still copy codes that people send each other in one-to-one chats:
- "Le code de la porte est 4821, je serai en retard" →
4821 - "Your code for the gym locker is 4821" →
4821 - "Ton code wifi est 48213579" →
48213579 - "Mon code PIN est 1234 lol" →
1234
Skipping Contacts makes sense. A cheaper signal is the sender's handle: short codes and alphanumeric senders (handle.id that is neither a phone number nor an e-mail) are where OTPs come from. One option is to accept the loose markers only from those senders and require the strict ones (verification/security/one-time code, code de vérification/connexion/sécurité, passcode, OTP) from a phone number or iMessage address. Small one: "code d'accès" is still missed because of the apostrophe.
5. Housekeeping — fixed. Rebased, registered in registerRealProviders(), demo fake, paired in the test contexts, a 5 s cooldown, tr() messages, CHANGELOG. Two notes:
- The CHANGELOG line is written for developers and points to a registry widget that can no longer install. It should say what a user can do, once they can do it (next point).
- The Sietch widget still matches the old English strings (
'Available only from this Mac.'etc.), which no longer match whattr()returns, and it has no case for "disabled" or "rate limited". A built-in widget can simply showresult.error, which is already localized.
What's left for merge. With built-in-only in place, nothing can call the provider yet: the admin would show a privacy switch for a feature no widget uses. So I'd like the widget to move into this PR as widgets/messages-2fa: the Sietch widget ported to a built-in, French and English strings, pnpm widget:preview for a screenshot, and the demo fake in place. Then the CHANGELOG line can describe the feature. Together with the JXA fix, the absolute path, the extraction tightening and the search label, I think this is ready.
Requesting changes for those, but this is close — thank you for taking every point seriously, the pasteboard ownership handling in particular is careful work.
A macOS denial on chat.db surfaced as the generic "Messages could not be read", indistinguishable from a schema or spawn failure. Tag the permission case in the sqlite runner and return a dedicated error that tells the user to enable Full Disk Access for Fremkit. Co-Authored-By: Claude <noreply@anthropic.com>
fdussert
left a comment
There was a problem hiding this comment.
Thanks Livio — the Full Disk Access message is a nice touch, and telling the user what's missing is much better than a generic read failure. I merged current main into 9fe2188 locally: only a CHANGELOG conflict, pnpm typecheck is clean and pnpm test passes. The points from my last review are still open, though, so here's where things stand:
- JXA clear (still the blocker).
board.clearContents()is still in both clear scripts (messages-2fa.ts:45,:116). I re-ran it on a private named pasteboard and it still throwsTypeError: board.clearContents is not a function, so every cleaner exits non-zero, the fallback fires, and each successful copy ends with a "cleanup failed" log line. Please switch both scripts toboard.clearContents;, update the assertions inmessages-2fa.test.ts:353,372, and add the macOS-only test that runs the three scripts againstNSPasteboard.pasteboardWithName(...)and thenreleaseGlobally. - Absolute path.
osascriptis still a bare name at:51and:62. Please use/usr/bin/osascript. - Extraction. All four one-to-one examples still copy (
4821,4821,48213579,1234), and "code d'accès" with a straight apostrophe is still missed. Gating the loose markers on the sender's handle (short codes and alphanumeric senders) and requiring the strict ones from phone numbers and e-mail addresses would cover it. - Settings search.
admin.inspector.screen.messages2FAstill needs adding to the Privacy entry'slabelsinsettingsWindow.ts. - The widget. It needs to come into this PR as
widgets/messages-2fa(FR/EN strings,pnpm widget:preview, demo fake). A built-in can just showresult.error, so the comparisons with the old English strings can go. Until then nothing can call the provider, and the admin would show a switch for a feature no widget uses. - Small ones. The permission message says "Fremkit", but macOS lists "Fremkit Helper" (or the terminal under
pnpm dev); naming what the user will actually see in System Settings would help. A test that feedsdefaultRun's classifier a realauthorization deniedstderr would cover the new branch. In the CHANGELOG, please fold the new "Fixed" entry into the single Added line: the feature hasn't shipped yet. Once the widget is here, that line can say what a user can do with it.
Still requesting changes, but the remaining work is well defined, and once the clear fix and the widget port are in, I think this is ready.
Every rule in isSecret started at eight characters, so a six-digit OTP copied from an SMS or an authenticator was recorded unmasked: shown on the Edge, kept in the 20-entry history, and sent to a paired iPad whose screen holds the clipboard widget. A text that is only four to eight digits, or two groups of three or four split by one space or dash, is now masked. It is tested before the whitespace rule so "482 913" counts. The rule is anchored on the whole text: digits inside prose, phone numbers (more digits, more groups) and lopsided splits are left alone. A bare year or postcode copied on its own is masked too, which costs a preview and nothing else. Found while reviewing PR fdussert#49. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Adds a default-off, local-only
messages-2faprovider for a built-in widget request. The provider reads only incoming Messages from the last five minutes (at most 100 rows) through read-only SQLite with a timeout, and copies a context-matched code on the host. The widget receives only{ ok: true }; database and pasteboard errors stay generic. The command is built-in-only and requires the separate Messages 2FA privacy setting, which defaults off.The pasteboard writer uses a fixed JXA script and sends the code over stdin, not argv. It marks the entry concealed, transient, and current-host-only. The writer captures the change count returned by
prepareForNewContentsWithOptions(CurrentHostOnly), checks the string and both metadata writes, verifies the same count before returning, and passes that captured count to delayed cleanup. Cleanup compareschangeCountbefore clearing, but the comparison and clear are separate AppKit calls; cleanup is best-effort, and real macOS/JXA behavior remains unverified.The matcher prefers verification-context numbers, handles English and French wording, skips date-shaped and account-ending numbers, excludes group chats, and rate-limits requests. Contact exclusion is not implemented; the provider does not request Contacts access.
This PR supplies the core provider only. The separate Sietch widget PR #16 remains outside this repository; marketplace widgets cannot invoke this built-in-only command, so trusted integration and the Sietch widget outcome remain unresolved.
Clipboard ownership race correction: commit
261592f83a32106b625daaadb7ef359e5876e052preserves the acquired pasteboard token and refuses to arm cleanup after failed metadata writes or detected ownership changes.Verification at
261592f83a32106b625daaadb7ef359e5876e052: focused Messages 2FA tests passed (21/21); full server suite passed (134 files, 2,699 tests, 2 skipped); server source and test TypeScript checks passed;git diff --checkpassed. Real Messages, pasteboard, JXA, or end-to-end widget behavior was not tested.