Skip to content

[Bug]: iMessage (imsg) channel - binary length prefix leaking into message content #63868

Description

@clawrenceandthemachine

Bug Report: iMessage (imsg) Channel - Binary Length Prefix Leaking into Message Content

Description

When receiving messages via the iMessage channel (using the imsg provider), every incoming message has binary junk prepended to the text content. This appears to be a length-prefix from the underlying protobuf/gRPC communication that is not being properly stripped.

Symptom

Every received message starts with binary characters (hex: variable varint-encoded length prefix) followed by the actual message text.

Example of raw message content:

��Mrrrrow! 🐱 Ich bin wach und bereit!

Expected:

Mrrrrow! 🐱 Ich bin wach und bereit!

Environment

  • OpenClaw version: 2026.4.9 (npm latest)
  • OS: macOS 26.3.1 (arm64)
  • Node: v22.22.1
  • Channel: iMessage (channel: imessage, provider: imsg)
  • imsg CLI: Installed via Homebrew at /opt/homebrew/bin/imsg
  • Gateway: local mode, running via LaunchAgent

Root Cause Hypothesis

The imsg bridge communicates with OpenClaw using protobuf/gRPC. The message payload includes a length-prefix (varint) that should be consumed during deserialization, but it's being passed through to the content instead. The binary bytes appear to be a protobuf varint length prefix that isn't being stripped by the channel handler.

Reproduction Steps

  1. Configure iMessage channel with imsg provider
  2. Send any message to the agent via iMessage
  3. Observe that the message field in context contains binary prefix characters
  4. The prefix is consistent across all messages (typically 2-4 bytes)

Impact

  • Functional: Low - text is still readable
  • UX: High annoyance factor
  • Compatibility: May break tools expecting clean text input
  • Token usage: Wastes tokens on binary data

Related Issues

May be related to other binary injection issues:

Suggested Fix

The iMessage channel handler should properly strip the protobuf length prefix before passing message content to the agent context.


To submit this bug report:

  1. Go to https://github.com/openclaw/openclaw/issues/new?template=bug_report.yml
  2. Copy the content above into the form
  3. Submit the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions