Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Element Web R can't send encrypted messages on dendrite/conduit #26566

Closed
2 tasks done
ninchuka opened this issue Nov 13, 2023 · 10 comments · Fixed by matrix-org/matrix-js-sdk#4033
Closed
2 tasks done
Assignees
Labels
A-Element-R Issues affecting the port of Element's crypto layer to Rust O-Uncommon Most users are unlikely to come across this or unexpected workflow S-Major Severely degrades major functionality or product features, with no satisfactory workaround T-Defect Team: Crypto Z-Element-R-Blocker A blocker for enabling Element R by default Z-Labs Z-Spec-Compliance An area where Element doesn't correctly implement the spec Z-Upstream

Comments

@ninchuka
Copy link

ninchuka commented Nov 13, 2023


Steps to reproduce

  1. Where are you starting? What can you see?
    sending encrypted message with rust SDK on dendrite
  2. What do you click?
    sending message in encrypted room
  3. More steps…

Outcome

What did you expect?

for message to be sent

What happened instead?

ele web says
Some of your messages have not been sent
You can select all or individual messages to retry or delete

while in the console I see, I have asked a user on another dendrite HS to double check its not a issue with the one I'm on and they saw it as well element web says Session key: <not supported> as well in the security & privacy area of settings

POST https://matrix.pain.agency/_matrix/client/v3/keys/upload 400 (Bad Request)
(anonymous) @ instrument.js:155
fetch @ fetch.ts:60
requestOtherUrl @ fetch.ts:304
request @ fetch.ts:241
authedRequest @ fetch.ts:159
rawJsonRequest @ OutgoingRequestProcessor.ts:198
makeOutgoingRequest @ OutgoingRequestProcessor.ts:74
processOutgoingRequests @ OutgoingRequestsManager.ts:133
await in processOutgoingRequests (async)
outgoingRequestLoop @ OutgoingRequestsManager.ts:109
doProcessOutgoingRequests @ OutgoingRequestsManager.ts:85
ensureEncryptionSession @ RoomEncryptor.ts:141
await in ensureEncryptionSession (async)
encryptEvent @ RoomEncryptor.ts:207
encryptEvent @ rust-crypto.ts:284
encryptEventIfNeeded @ client.ts:4740
(anonymous) @ client.ts:4637
Promise.then (async)
encryptAndSendEvent @ client.ts:4636
resendEvent @ client.ts:4315
resend @ Resend.ts:48
(anonymous) @ Resend.ts:31
resendUnsentEvents @ Resend.ts:30
(anonymous) @ RoomStatusBar.tsx:137
Rb @ react-dom.production.min.js:52
Xb @ react-dom.production.min.js:52
Yb @ react-dom.production.min.js:53
Ze @ react-dom.production.min.js:100
se @ react-dom.production.min.js:101
(anonymous) @ react-dom.production.min.js:113
Jb @ react-dom.production.min.js:292
Nb @ react-dom.production.min.js:50
jd @ react-dom.production.min.js:105
yc @ react-dom.production.min.js:75
hd @ react-dom.production.min.js:74
exports.unstable_runWithPriority @ scheduler.production.min.js:18
gg @ react-dom.production.min.js:122
Hb @ react-dom.production.min.js:292
gd @ react-dom.production.min.js:73
rageshake.ts:74 Failed to process outgoing request 0: Unknown error code: MatrixError: [400] Unknown message (https://matrix.pain.agency/_matrix/client/v3/keys/upload)
consoleObj.<computed> @ rageshake.ts:74
(anonymous) @ instrument.js:125
(anonymous) @ logger.ts:94
processOutgoingRequests @ OutgoingRequestsManager.ts:137
await in processOutgoingRequests (async)
outgoingRequestLoop @ OutgoingRequestsManager.ts:109
doProcessOutgoingRequests @ OutgoingRequestsManager.ts:85
ensureEncryptionSession @ RoomEncryptor.ts:141
await in ensureEncryptionSession (async)
encryptEvent @ RoomEncryptor.ts:207
encryptEvent @ rust-crypto.ts:284
encryptEventIfNeeded @ client.ts:4740
(anonymous) @ client.ts:4637
Promise.then (async)
encryptAndSendEvent @ client.ts:4636
resendEvent @ client.ts:4315
resend @ Resend.ts:48
(anonymous) @ Resend.ts:31
resendUnsentEvents @ Resend.ts:30
(anonymous) @ RoomStatusBar.tsx:137
Rb @ react-dom.production.min.js:52
Xb @ react-dom.production.min.js:52
Yb @ react-dom.production.min.js:53
Ze @ react-dom.production.min.js:100
se @ react-dom.production.min.js:101
(anonymous) @ react-dom.production.min.js:113
Jb @ react-dom.production.min.js:292
Nb @ react-dom.production.min.js:50
jd @ react-dom.production.min.js:105
yc @ react-dom.production.min.js:75
hd @ react-dom.production.min.js:74
exports.unstable_runWithPriority @ scheduler.production.min.js:18
gg @ react-dom.production.min.js:122
Hb @ react-dom.production.min.js:292
gd @ react-dom.production.min.js:73
instrument.js:155 
        
        
       POST https://matrix.pain.agency/_matrix/client/v3/keys/claim 400 (Bad Request)
(anonymous) @ instrument.js:155
fetch @ fetch.ts:60
requestOtherUrl @ fetch.ts:304
request @ fetch.ts:241
authedRequest @ fetch.ts:159
rawJsonRequest @ OutgoingRequestProcessor.ts:198
makeOutgoingRequest @ OutgoingRequestProcessor.ts:78
ensureSessionsForUsersInner @ KeyClaimManager.ts:76
await in ensureSessionsForUsersInner (async)
(anonymous) @ KeyClaimManager.ts:64
Promise.then (async)
ensureSessionsForUsers @ KeyClaimManager.ts:64
ensureEncryptionSession @ RoomEncryptor.ts:149
await in ensureEncryptionSession (async)
encryptEvent @ RoomEncryptor.ts:207
encryptEvent @ rust-crypto.ts:284
encryptEventIfNeeded @ client.ts:4740
(anonymous) @ client.ts:4637
Promise.then (async)
encryptAndSendEvent @ client.ts:4636
resendEvent @ client.ts:4315
resend @ Resend.ts:48
(anonymous) @ Resend.ts:31
resendUnsentEvents @ Resend.ts:30
(anonymous) @ RoomStatusBar.tsx:137
Rb @ react-dom.production.min.js:52
Xb @ react-dom.production.min.js:52
Yb @ react-dom.production.min.js:53
Ze @ react-dom.production.min.js:100
se @ react-dom.production.min.js:101
(anonymous) @ react-dom.production.min.js:113
Jb @ react-dom.production.min.js:292
Nb @ react-dom.production.min.js:50
jd @ react-dom.production.min.js:105
yc @ react-dom.production.min.js:75
hd @ react-dom.production.min.js:74
exports.unstable_runWithPriority @ scheduler.production.min.js:18
gg @ react-dom.production.min.js:122
Hb @ react-dom.production.min.js:292
gd @ react-dom.production.min.js:73
rageshake.ts:74 Error sending event M_BAD_JSON: MatrixError: [400] The request body could not be decoded into valid JSON. json: cannot unmarshal object into Go struct field claimKeysRequest.timeout of type int (https://matrix.pain.agency/_matrix/client/v3/keys/claim)
    at parseErrorResponse (https://develop.element.io/bundles/c95983ad3677cd7691c4/bundle.js:118899:12)
    at MatrixHttpApi.requestOtherUrl (https://develop.element.io/bundles/c95983ad3677cd7691c4/bundle.js:234520:86)
    at async MatrixHttpApi.authedRequest (https://develop.element.io/bundles/c95983ad3677cd7691c4/bundle.js:234361:24)
    at async OutgoingRequestProcessor.rawJsonRequest (https://develop.element.io/bundles/c95983ad3677cd7691c4/34.js:1973:12)
    at async OutgoingRequestProcessor.makeOutgoingRequest (https://develop.element.io/bundles/c95983ad3677cd7691c4/34.js:1891:14)
    at async KeyClaimManager.ensureSessionsForUsersInner (https://develop.element.io/bundles/c95983ad3677cd7691c4/34.js:2053:7)
    at async RoomEncryptor.ensureEncryptionSession (https://develop.element.io/bundles/c95983ad3677cd7691c4/34.js:1746:5)
    at async RoomEncryptor.encryptEvent (https://develop.element.io/bundles/c95983ad3677cd7691c4/34.js:1795:5)
    at async RustCrypto.encryptEvent (https://develop.element.io/bundles/c95983ad3677cd7691c4/34.js:364:5)
    at async Promise.all (index 0)

Operating system

Fedora 38

Browser information

Chrome 119.0.6045.123

URL for webapp

https://develop.element.io/

Application version

Element version: 781a067-react-6ee8349f7ce6-js-7de9b23e5993 Crypto version: Rust SDK 0.6.0 (17d4f2f), Vodozemac 0.5.0

Homeserver

pain.agency Dendrite 0.13.4+317b101

Will you send logs?

Yes

@ninchuka
Copy link
Author

it also doesnt work on conduit either, getting a friend to send a rageshake of it failing on conduit as well

@jjj333-p
Copy link

Adding some context as the sysadmin of pain.agency, i see the following error a lot in my logs (when dendrite isn't shitting itself about something else, as it does) which appears to be related to this bug

Nov 13 21:49:56 snapshot-115842185-debian-2gb-hil-1 dendrite[387921]: time="2023-11-13T21:49:56.598560396Z" level=error msg="Failed to upload one or more keys" key_errors="map[@j:pain.agency:map[0ZZeMt1g:user_id or device_id mismatch: users: - @j:pain.agency, devices: - 0ZZeMt1g]]" req.id=JD2decX9Cwh8 req.method=POST req.path=/_matrix/client/v3/keys/upload user_id="@j:pain.agency"

( @j:pain.agency is @ninja85a )

Unsure if this is a bug on the dendrite side causing it to fail or if something is awry in how element is handling it

@S7evinK
Copy link

S7evinK commented Nov 15, 2023

If I didn't do anything wrong, this seems to be an issue in ruma?

/keys/upload contains device_keys: null (which should be absent as per the spec).
/keys/claim has timeout":{"nanos":0,"secs":10} in the request body, which should be a plain integer. (this is where e.g. Dendrite falls over with json: cannot unmarshal object into Go struct field claimKeysRequest.timeout of type int

@ninchuka ninchuka changed the title ele web with rusk SDK cant send encrypted messages on dendrite HS ele web with rusk SDK cant send encrypted messages on dendrite/conduit Nov 15, 2023
@t3chguy t3chguy added Z-Upstream Z-Spec-Compliance An area where Element doesn't correctly implement the spec Team: Crypto A-Element-R Issues affecting the port of Element's crypto layer to Rust Z-Element-R-Blocker A blocker for enabling Element R by default labels Nov 15, 2023
@t3chguy
Copy link
Member

t3chguy commented Nov 15, 2023

image

The request body is built by the Rust SDK

This looks like matrix-org/matrix-rust-sdk#801 which is claimed to be fixed - wonder if it regressed

cc @richvdh

@t3chguy t3chguy added S-Major Severely degrades major functionality or product features, with no satisfactory workaround O-Uncommon Most users are unlikely to come across this or unexpected workflow labels Nov 16, 2023
@richvdh
Copy link
Member

richvdh commented Nov 16, 2023

This looks like matrix-org/matrix-rust-sdk#801 which is claimed to be fixed - wonder if it regressed

Looks like it was fixed in the nodejs bindings but not the wasm bindings. Arguably it's silly that it is being done in the bindings at all.

Have filed matrix-org/matrix-rust-sdk-crypto-wasm#56 and matrix-org/matrix-rust-sdk-crypto-wasm#57 to track this on the Rust side.

@richvdh richvdh changed the title ele web with rusk SDK cant send encrypted messages on dendrite/conduit Element Web R ele web with rusk SDK cant send encrypted messages on dendrite/conduit Nov 16, 2023
@richvdh richvdh changed the title Element Web R ele web with rusk SDK cant send encrypted messages on dendrite/conduit Element Web R can't send encrypted messages on dendrite/conduit Nov 16, 2023
@richvdh
Copy link
Member

richvdh commented Nov 24, 2023

We believe we can make a quick fix for this in the wasm bindings, and will do so for Element-R release.

@uhoreg
Copy link
Member

uhoreg commented Jan 23, 2024

This is fixed in matrix-sdk-crypto-wasm v4.0.0, which matrix-js-sdk now depends on, so it should be fixed in the next release of Element R

@uhoreg uhoreg closed this as completed Jan 23, 2024
@richvdh
Copy link
Member

richvdh commented Jan 23, 2024

This is fixed in matrix-sdk-crypto-wasm v4.0.0

I don't think that's right. matrix-sdk-crypto-wasm v4.0.0 does not include matrix-org/matrix-rust-sdk-crypto-wasm#72.

@richvdh richvdh reopened this Jan 23, 2024
@richvdh
Copy link
Member

richvdh commented Jan 23, 2024

[it would be good to have some tests at the js-sdk level to prove this one way or another.]

@richvdh
Copy link
Member

richvdh commented Jan 23, 2024

matrix-sdk-crypto-wasm v4.0.1 does include the fix, so this will probably be fixed by matrix-org/matrix-js-sdk#4025, but given a test should be trivial: please can we do so?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Element-R Issues affecting the port of Element's crypto layer to Rust O-Uncommon Most users are unlikely to come across this or unexpected workflow S-Major Severely degrades major functionality or product features, with no satisfactory workaround T-Defect Team: Crypto Z-Element-R-Blocker A blocker for enabling Element R by default Z-Labs Z-Spec-Compliance An area where Element doesn't correctly implement the spec Z-Upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants