Skip to content
This repository has been archived by the owner on Mar 2, 2024. It is now read-only.

"Mismatched SHA-256 digest" when bridging attachments to Facebook #305

Open
deetris opened this issue May 14, 2023 · 0 comments
Open

"Mismatched SHA-256 digest" when bridging attachments to Facebook #305

deetris opened this issue May 14, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@deetris
Copy link

deetris commented May 14, 2023

I recently started getting these errors quite a lot. The scenario is quite simple:

  • I send an attachment over Matrix
  • The Facebook bot responds with: "⚠ Your message may not have been bridged: Mismatched SHA-256 digest"
  • The Facebook user does not receive the attachment

Note that it happens only sometimes. I've sent tens of files in order to try to debug this issue and so far I have not seen any patterns in the behavior - seems to be quite random. Even sending the same file multiple times may sometimes fail and sometimes succeed.

So far I was able to reproduce it with multiple different JPEGs, PNGs, WAVs, OGGs and MP3s, so it seems that it doesn't depend on the type of the attachment. However, sending smaller files (under about 250 KiB or so) seems to work fine, but maybe I was just lucky.

I had this happen when sending attachments from both the desktop and mobile versions of Element. I'm running version 1.82.0 of Synapse and version 0.4.1 of the bridge (from the dock.mau.dev/mautrix/facebook:v0.4.1 Docker image).

Whenever it happens, the logs of the bridge show this:

[2023-05-14 17:45:25,864] [[email protected]] Received Matrix event $k9eI9b9BuiBGt_v19x3q-3XSc6hV0tYztM4bQ9OnvFo from @<someone>:matrix.dtris.moe in !<some room>:matrix.dtris.moe
[2023-05-14 17:45:25,920] [[email protected].<some FB id><-><not sure what this is>] Failed to handle Matrix event $k9eI9b9BuiBGt_v19x3q-3XSc6hV0tYztM4bQ9OnvFo
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/mautrix_facebook/portal.py", line 840, in handle_matrix_message
    await self._handle_matrix_message(sender, message, event_id)
  File "/usr/lib/python3.10/site-packages/mautrix_facebook/portal.py", line 866, in _handle_matrix_message
    await self._handle_matrix_media(event_id, sender, message, is_relay)
  File "/usr/lib/python3.10/site-packages/mautrix_facebook/portal.py", line 911, in _handle_matrix_media
    data = decrypt_attachment(
  File "/usr/lib/python3.10/site-packages/mautrix/crypto/attachments/attachments.py", line 55, in decrypt_attachment
    raise DecryptionError("Mismatched SHA-256 digest")
mautrix.errors.crypto.DecryptionError: Mismatched SHA-256 digest
[2023-05-14 17:45:25,920] [[email protected]] Encrypting event of type m.room.message for !<some room>:matrix.dtris.moe
[2023-05-14 17:45:25,962] [[email protected].@facebook_<some FB id>:matrix.dtris.moe] req #973: PUT https://matrix.dtris.moe/_matrix/client/v3/rooms/%21<some room>%3Amatrix.dtris.moe/send/m.room.encrypted/mautrix-python_1684086325962299121_30?user_id=@facebook_<some FB id>:matrix.dtris.moe {"ciphertext": "AwgbEtABudm3z4S1nlfyxphKXvu8qghvDVJMR2PjwEBx14RLUOgA9WxoTB1UclraTeHSBgFTATXFuMRS54+bVSt5TXNMA43dI1ximuwZLJd0a0wdh/Lvcne4IHMYifsHWgq62DyYZWejveby22nekh2/IDNPcfcpmIgIt8u4X3ImvtpYsqFvxdteBMZ5gkc/HCM6b7A7dLAwR1Qt5thv4NvTJ+oqNR3Xsv0g0WJuacVmKhvWoco81DTf9Ax0lsan+S0Ny1mKWl2awwrs8yUgsDWdA8Q3xN6ow/sk+wzHl2HwJJYlOsMzvAVhTSTYmp2A+uRvfgaFOrm6sdIBB6qoLRbs+PS5281GXdAVMbc59nHKLxQ3SY8OqdV6EdHCDQ", "session_id": "6L0/eUFNDsL7tIi6sreKS/EWOgx+AgaL6bp2C1EX9sc", "algorithm": "m.megolm.v1.aes-sha2", "sender_key": "zvsONDfQVU/NxJqYXZI2HLGoey3RwVU2eHWT163pr0c", "device_id": "IOUIVFEAKX"}
[2023-05-14 17:45:25,991] [[email protected].@facebook_<some FB id>:matrix.dtris.moe] req #973 (/v3/rooms/%21<some room>%3Amatrix.dtris.moe/send/m.room.encrypted/mautrix-python_1684086325962299121_30) completed in 28.4ms with status 200

I assume that the two last three lines are just the bridge sending the "Your message may not have been bridged" notice, so those are probably not that important.

So, any ideas what could be wrong? Is there anything that I can do to debug this further?

@deetris deetris added the bug Something isn't working label May 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant