fix(xmtp): render reply inner content instead of dumping raw JSON#82
Merged
Conversation
normalizeMessageContent serialized a reply's inner content with JSON.stringify when it wasn't a string. For a reply carrying a remote attachment that dumped the decoded envelope verbatim — including the AES key material (secret/salt/nonce) — into the message text the agent sees. Render the inner content through normalizeMessageContent using the inner contentType the decoded reply carries, so a reply-wrapped remote/inline attachment (or any nested content) becomes its display string, e.g. `reply to "…": [remote attachment: photo.jpg (… bytes) https://…]`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SRUJWMudi3sSaGffXyzk52
ApprovabilityVerdict: Approved Small, focused bug fix that prevents AES key material from leaking into message text by reusing the existing content normalizer for nested reply payloads. The change improves security, is well-tested, and follows established patterns in the codebase. You can customize Macroscope's approvability policy. Learn more. |
neekolas
approved these changes
Jun 24, 2026
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.
Summary
normalizeMessageContentserialized a reply's inner content withJSON.stringifywhenever it wasn't a string. For a reply that carries a remote attachment (someone replies to a message with a photo), that dumped the decoded attachment envelope verbatim into the message text — including the AES key material (secret/salt/nonce) — instead of the[remote attachment: …]display string. Downstream consumers (e.g. the Herald agent webhook) then handed that raw blob to the agent.This renders the reply's inner content through
normalizeMessageContentrecursively, using the innercontentTypethe decodedEnrichedReplyalready carries, so a reply-wrapped remote/inline attachment (or any nested content) becomes its display string:A text reply still hits the existing string fast-path; an unknown inner type falls back to the prior JSON behavior.
Why
A reply was the one path that never delegated to the per-type renderers below it, so it was the only way encryption key material leaked into agent-visible text.
Tests
Added
normalizeMessageContentcoverage: text reply, reply→remote attachment (asserts nosecret/salt/noncein output), reply→inline attachment, and the unknown-type JSON fallback.🤖 Generated with Claude Code
https://claude.ai/code/session_01SRUJWMudi3sSaGffXyzk52
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Note
Fix
normalizeMessageContentto render reply inner content instead of raw JSONReplies carrying non-text payloads (e.g. remote/inline attachments) previously serialized the decoded content as raw JSON, which could expose key material.
normalizeMessageContentin xmtp.ts now reads the innercontentTypeof a reply and recursively normalizes it; it falls back toJSON.stringifyonly for unknown content types. New tests in xmtp.test.ts cover plain text, text replies, attachment replies, and the JSON fallback path.Macroscope summarized 15c464b.