Skip to content

fix(matrix): decrypt encrypted media attachments in E2EE rooms - #1744

Closed
araa47 wants to merge 2 commits into
openclaw:mainfrom
araa47:fix/matrix-encrypted-media-decryption
Closed

araa47 wants to merge 2 commits into
openclaw:mainfrom
araa47:fix/matrix-encrypted-media-decryption

Conversation

@araa47

@araa47 araa47 commented Jan 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes encrypted media (images, audio recordings, files) not being decrypted in Matrix E2EE rooms.

Previously, when users sent images or audio recordings in encrypted Matrix rooms, the bot would fail to decrypt them. Text messages worked fine, but media attachments were broken.

Root Cause

The decryptMedia function from matrix-bot-sdk's CryptoClient was being called with incorrect parameters:

// Before (broken) - passing 2 args
const decrypted = await params.client.crypto.decryptMedia(
  Buffer.from(encryptedBuffer),
  params.file,
);

However, according to the matrix-bot-sdk documentation, decryptMedia takes only a single EncryptedFile parameter and handles the download internally:

// Correct signature
public async decryptMedia(file: EncryptedFile): Promise<Buffer>

Fix

  • Call decryptMedia(file) with just the EncryptedFile object
  • Remove redundant manual download (the SDK handles it internally)
  • Move size check to after decryption

Testing

  • Unit tests updated and passing
  • Tested on live Matrix E2EE room with encrypted image attachments

🤖 Generated with Claude Code

Claude Sandbox added 2 commits January 25, 2026 16:27
…ments

The matrix-bot-sdk CryptoClient.decryptMedia() method takes only a single
EncryptedFile parameter and handles the download internally. The previous
code incorrectly passed both a downloaded buffer and the file object.

This fix:
- Removes redundant manual download (decryptMedia handles it)
- Passes only the EncryptedFile to decryptMedia as expected
- Moves size check to after decryption
@steipete steipete self-assigned this Jan 25, 2026
steipete added a commit that referenced this pull request Jan 25, 2026
@steipete

Copy link
Copy Markdown
Contributor

Landed via squash on main: 026def6.

  • Matrix: use crypto.decryptMedia(file), preflight size guard from info.size, add oversize test.

Tests:

  • pnpm lint (fails: no-redundant-type-constituents in src/line/*)
  • pnpm build (fails: missing @line/bot-sdk types)
  • pnpm test (timed out; existing failures in telegram + memory-lancedb suites)

Thanks @araa47!

@steipete steipete closed this Jan 25, 2026
rodrigouroz pushed a commit to rodrigouroz/openclaw that referenced this pull request Jan 26, 2026
dgarson pushed a commit to dgarson/clawdbot that referenced this pull request Feb 2, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
zeekay pushed a commit to Dream-AI-4444/bot that referenced this pull request Sep 11, 2026
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants