Executive brief
matrix-js-sdk is a JavaScript client library for the Matrix messaging protocol, used by many popular encrypted chat applications. The library incorrectly accepted encrypted message keys from any source, allowing an attacker cooperating with a malicious Matrix server to forge messages appearing to come from other users. While such forged messages display a warning shield on some platforms, this protection may be missing or ineffective on others.
Technical details
This vulnerability affects the key forwarding mechanism in matrix-js-sdk, which normally allows clients to recover encrypted messages they missed (e.g., when accessing chat history or after network errors). The SDK implemented an overly permissive policy by accepting forwarded encryption keys from untrusted sources without sufficient validation. An attacker colluding with a malicious homeserver can exploit this to send specially crafted Megolm session keys, allowing them to construct messages that appear to originate from legitimate users. The fix tightens the forwarding policy to only accept keys in response to explicit requests and only from the user's own verified devices. Additionally, a "trusted" flag is now set on decrypted messages to indicate key source trustworthiness, requiring clients to display appropriate warnings for untrusted keys. The vulnerability was patched in matrix-js-sdk v19.7.0 released on 2022-09-28.
Affected products
- matrix-org matrix-js-sdk all versions before 19.7.0
Timeline
- 2022-09-28: disclosed
- 2022-09-28: patched: matrix-js-sdk v19.7.0 released
References
- https://github.com/matrix-org/matrix-js-sdk/security/advisories/GHSA-6263-x97c-c4gg
- https://github.com/matrix-org/matrix-spec-proposals/pull/3061
- https://github.com/matrix-org/matrix-js-sdk/commit/a587d7c36026fe1fcf93dfff63588abee359be76
- https://github.com/matrix-org/matrix-js-sdk
- https://github.com/matrix-org/matrix-js-sdk/releases/tag/v19.7.0
- https://matrix.org/blog/2022/09/28/upgrade-now-to-address-encryption-vulns-in-matrix-sdks-and-clients