Skip to content

typing: IMChatRegistry never populates — entitlement blocker + any;-; GUID mismatch #58

@alexrudloff

Description

@alexrudloff

Summary

imsg typing is broken by two stacked bugs. Fixing either one alone won't make typing work. This consolidates #51, #54, and #56 with root cause analysis.

Bug 1: GUID prefix mismatch (any;-; vs iMessage;-;)

When using --to, ChatTargetResolver.directTypingIdentifier() constructs iMessage;-;+number but the actual chat.db GUID is any;-;+number on modern macOS (Sequoia, Apple Silicon).

SELECT ROWID, guid, chat_identifier FROM chat;
-- 1|any;-;+12025551212|+12025551212

The --chat-id path works correctly (reads the GUID from DB and uses it as-is), but the --to path hardcodes the wrong prefix.

Fix: directTypingIdentifier() should read the actual GUID from chat.db for the recipient instead of constructing one. Or try all known prefixes (any;-;, iMessage;-;, SMS;-;).

Bug 2: IMChatRegistry never populates (entitlement blocker)

This is the real blocker. Even with the correct GUID, existingChatWithGUID: and existingChatWithChatIdentifier: return nil because IMCore's chat registry is empty.

What we tested (macOS 15.3, SIP disabled):

  1. connectToDaemon succeeds but isConnected stays false
  2. connectToDaemonWithLaunch:capabilities:blockUntilConnected: — crashes with NSProxy forwardInvocation: (the daemon controller is a remote proxy that can't forward the call)
  3. blockUntilConnected — same NSProxy crash
  4. Retry loop with RunLoop.current.run() pumping for 10+ seconds — registry never populates
  5. Ad-hoc codesigning with private entitlements (com.apple.private.imcore.imhandle, com.apple.private.ids.messaging) — AMFI kills the process with SIGKILL even with SIP disabled

Root cause: IMChatRegistry populates via XPC messages from imagent. The XPC connection requires Apple-internal entitlements that third-party binaries cannot claim without a valid Apple provisioning profile. AMFI enforces this even with SIP disabled.

Evidence: amfid log confirms the kill:

amfid: Restricted entitlements not validated, bailing out. 
Error Domain=AppleMobileFileIntegrityError Code=-420 "The signature on the file is invalid"

Impact

Typing indicators are completely non-functional on any;-; GUID systems (which appears to be most/all modern macOS setups). Bug 1 is fixable. Bug 2 may require a fundamentally different approach:

  • Injecting into Messages.app's process space (has the entitlements)
  • Using XPC to talk to imagent through Messages.app
  • AppleScript bridge (Messages.app scripting dictionary doesn't expose typing, but could potentially be extended)
  • Xcode project with development signing (uncertain if Apple allows private entitlements even with dev profile)

Environment

  • imsg 0.5.0 (Homebrew)
  • macOS 15.3 Sequoia, Apple Silicon (Mac Mini M4)
  • SIP disabled via csrutil
  • Messages.app running, imagent active
  • All chats use any;-; GUID prefix

Related

Consolidates #51, #54, #56

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions