element-web icon indicating copy to clipboard operation
element-web copied to clipboard

Unexplained Decryption failure due to "Unable to decrypt attachment: Mismatched SHA-256 digest"

Open richvdh opened this issue 1 year ago • 1 comments

A user reported a decryption failure on a message containing an image.

The logs contain no megolm decryption failure, but they do have:

2024-10-21T09:53:11.961Z E Unable to decrypt attachment:  Mismatched SHA-256 digest
./node_modules/matrix-encrypt-attachment/lib/browser-encrypt-attachment.js/</<[1]</decryptAttachment/</<@https://develop.element.io/bundles/08f5e67c245583e16087/7530.js:41217:31
step@https://develop.element.io/bundles/08f5e67c245583e16087/7530.js:41152:23
./node_modules/matrix-encrypt-attachment/lib/browser-encrypt-attachment.js/</<[1]</__generator</verb/<@https://develop.element.io/bundles/08f5e67c245583e16087/7530.js:41133:53
fulfilled@https://develop.element.io/bundles/08f5e67c245583e16087/7530.js:41124:58

I am at a loss to explain why the digest would be a mismatch.

The logs are unhelpful; they lack key information such as:

  • The URL of the media that could not be decrypted
  • The event for which the error occurred
  • Whether it was the thumbnail or full image (see also https://github.com/element-hq/element-web/issues/28311)
  • it might also be helpful to record the size of the file (to see if it was truncated in transit), the expected mac, and the actual mac.

richvdh avatar Oct 28 '24 12:10 richvdh

In one instance of this, the downloaded file was binary data that ended with

{"errcode":"M_UNKNOWN","error":"unexpected error","mr_errcode":"M_UNKNOWN"}

So something went wrong on the server.

uhoreg avatar Jun 10 '25 15:06 uhoreg