Giter VIP home page Giter VIP logo

Comments (7)

KitsuneRal avatar KitsuneRal commented on August 22, 2024 1

Sorry for taking time. Ok, if you want to try this guess out, here's what I would do.

First, enable the E2EE logging category (see the library's README how to do that; you need quotient.e2ee.debug=true, namely). Reproduce the problem (if Tobias' guess is right, it probably doesn't matter whether the trigger is time or the number of messages, so to save time you can just send 100 messages in an encrypted room). When the Megolm session gets rotated, you will see a message in the logs: "Creating new outbound megolm session". If it doesn't occur and other clients stop being able to decrypt the events - there's a problem even with the session creation; but this is unlikely.

So if that message in the logs shows up - the code that actually sends the new session key is inside Connection::sendSessionKeyToDevices() (see connection.cpp) and it's called from Room::Private::doSendEvent(). Again, you will see in the logs if that actually happens, the message should be "Sending room key to devices", with the new session ID following. If that doesn't happen - you'll have to debug R::P::doSendEvent() to understand why it doesn't call C::sendSessionKeyToDevices().

Now, if that message is also there in the logs, we have to go through sendSessionKeyToDevices() in order to understand two things: 1) whether it collects the right list of target devices (again, you can see it from the logs but you might even want to break and step over the loop in the beginning of the method); and 2) whether it actually sends the request - this can also be found from the logs (each request is sent within a "job" so you need to have quotient.jobs.debug logging category enabled to check this), if the request is actually sent you should see a bunch of log lines about the /sendToDevice job.

Let me know about your findings :)

from libquotient.

Akselmo avatar Akselmo commented on August 22, 2024

The bug happened again. Took 5 days for it to happen, so I guess 5 days is when the encryption key needs to be sent to the new megolm session?

from libquotient.

Akselmo avatar Akselmo commented on August 22, 2024

Ok, I can try to look into this When I Got Time™️ Thanks for the explanation.

But of course if you or anyone else who might be reading this figures it out before me, no need to wait for me! 😂

from libquotient.

Akselmo avatar Akselmo commented on August 22, 2024

I have now confirmed that the bug happens after 100 messages. I used this tiny script with Neochat to confirm it

import os
import time

print("Starting message spam from 1 to 104")
time.sleep(5)
for i in range(1,105):
    os.system(f"ydotool type {i}")
    time.sleep(0.5)
    os.system("ydotool key 28:1 28:0")
    time.sleep(1)

print("Done")

I see if I can get some logs as well

from libquotient.

Akselmo avatar Akselmo commented on August 22, 2024

Here's some E2EE logs from the moment the key changes

quotient.e2ee: Encrypted event from "@akselmo:matrix.akselmo.dev"
quotient.e2ee: Sending room key to devices: "dUCrsgKk3ld7o3CZfjpCeAEPzrRkyLRAOKjaLkt5kW4" 99
quotient.e2ee: Encrypted event from "@akselmo:matrix.akselmo.dev"
quotient.e2ee: Creating new outbound megolm session for room  "!NenIgaqPaTYiyHsFgQ:matrix.org"
quotient.e2ee: Allocated 256 bytes of secure heap (requested 160 bytes), 608 / 65536 bytes of secure heap used in total
quotient.e2ee: Deallocated 256 bytes, 352 / 65536 bytes of secure heap used

// The following keys stop working

quotient.e2ee: Adding inbound session "F4XBS129dMeJ5pBVCSkzM6M8I62kTTx/i/O+/u6oxgs"
quotient.e2ee: Sending room key to devices: "F4XBS129dMeJ5pBVCSkzM6M8I62kTTx/i/O+/u6oxgs" 0
quotient.e2ee: Encrypted event from "@akselmo:matrix.akselmo.dev"
quotient.e2ee: Consuming 1 to-device events
quotient.e2ee: Sending room key to devices: "F4XBS129dMeJ5pBVCSkzM6M8I62kTTx/i/O+/u6oxgs" 1
quotient.e2ee: Encrypted event from "@akselmo:matrix.akselmo.dev"
quotient.e2ee: Sending room key to devices: "F4XBS129dMeJ5pBVCSkzM6M8I62kTTx/i/O+/u6oxgs" 2
quotient.e2ee: Encrypted event from "@akselmo:matrix.akselmo.dev"
quotient.e2ee: Consuming 1 to-device events

from libquotient.

Akselmo avatar Akselmo commented on August 22, 2024

Here's with jobs debug log enabled

quotient.e2ee: Sending room key to devices: "P6hFlWi0MYN2pqOmu/H9cdwDWAG/j2XyJVH871mJOUA" 99
quotient.jobs: Sent PUT https://matrix.akselmo.dev/_matrix/client/v3/rooms/%21NenIgaqPaTYiyHsFgQ%3Amatrix.org/send/m.room.encrypted/DYVKWTJDNI1678544590874201
quotient.jobs: Sent PUT https://matrix.akselmo.dev/_matrix/client/v3/rooms/%21NenIgaqPaTYiyHsFgQ%3Amatrix.org/typing/%40akselmo%3Amatrix.akselmo.dev
quotient.jobs: 200 <- PUT https://matrix.akselmo.dev/_matrix/client/v3/rooms/%21NenIgaqPaTYiyHsFgQ%3Amatrix.org/typing/%40akselmo%3Amatrix.akselmo.dev
quotient.jobs: "SetTypingJob" destroyed
quotient.jobs: Sent GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: 200 <- PUT https://matrix.akselmo.dev/_matrix/client/v3/rooms/%21NenIgaqPaTYiyHsFgQ%3Amatrix.org/send/m.room.encrypted/DYVKWTJDNI1678544590874201
quotient.jobs: "SendMessageJob" destroyed
quotient.e2ee: Encrypted event from "@akselmo:matrix.akselmo.dev"
quotient.jobs: 200 <- GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: Sent GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: "GetNotificationsJob" destroyed
quotient.jobs: 200 <- GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: "GetNotificationsJob" destroyed
quotient.jobs: Sent POST https://matrix.akselmo.dev/_matrix/client/v3/rooms/%21NenIgaqPaTYiyHsFgQ%3Amatrix.org/read_markers
quotient.jobs: 200 <- POST https://matrix.akselmo.dev/_matrix/client/v3/rooms/%21NenIgaqPaTYiyHsFgQ%3Amatrix.org/read_markers
quotient.jobs: Sent GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: "SetReadMarkerJob" destroyed
quotient.jobs: Sent PUT https://matrix.akselmo.dev/_matrix/client/v3/rooms/%21NenIgaqPaTYiyHsFgQ%3Amatrix.org/typing/%40akselmo%3Amatrix.akselmo.dev
quotient.jobs: Sent GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: 200 <- GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: "GetNotificationsJob" destroyed
quotient.jobs: 200 <- PUT https://matrix.akselmo.dev/_matrix/client/v3/rooms/%21NenIgaqPaTYiyHsFgQ%3Amatrix.org/typing/%40akselmo%3Amatrix.akselmo.dev
quotient.jobs: "SetTypingJob" destroyed
quotient.jobs: Sent GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: 200 <- GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: "GetNotificationsJob" destroyed
quotient.jobs: 200 <- GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: "GetNotificationsJob" destroyed
quotient.e2ee: Creating new outbound megolm session for room  "!NenIgaqPaTYiyHsFgQ:matrix.org"
quotient.e2ee: Allocated 256 bytes of secure heap (requested 160 bytes), 624 / 65536 bytes of secure heap used in total
quotient.e2ee: Deallocated 256 bytes, 368 / 65536 bytes of secure heap used
quotient.e2ee: Adding inbound session "DSpBcQ2LBG7v7iGgCDgyB/o8OyUqwVq33RHdceG6n/c"
quotient.e2ee: Sending room key to devices: "DSpBcQ2LBG7v7iGgCDgyB/o8OyUqwVq33RHdceG6n/c" 0
quotient.jobs: Sent PUT https://matrix.akselmo.dev/_matrix/client/v3/rooms/%21NenIgaqPaTYiyHsFgQ%3Amatrix.org/send/m.room.encrypted/DYVKWTJDNI1678544590874203
quotient.jobs: Sent PUT https://matrix.akselmo.dev/_matrix/client/v3/rooms/%21NenIgaqPaTYiyHsFgQ%3Amatrix.org/typing/%40akselmo%3Amatrix.akselmo.dev
quotient.jobs: 200 <- PUT https://matrix.akselmo.dev/_matrix/client/v3/rooms/%21NenIgaqPaTYiyHsFgQ%3Amatrix.org/typing/%40akselmo%3Amatrix.akselmo.dev
quotient.jobs: "SetTypingJob" destroyed
quotient.jobs: Sent GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: 200 <- PUT https://matrix.akselmo.dev/_matrix/client/v3/rooms/%21NenIgaqPaTYiyHsFgQ%3Amatrix.org/send/m.room.encrypted/DYVKWTJDNI1678544590874203
quotient.jobs: "SendMessageJob" destroyed
quotient.jobs: 200 <- GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.e2ee: Encrypted event from "@akselmo:matrix.akselmo.dev"
quotient.jobs: "GetNotificationsJob" destroyed
quotient.jobs: Sent GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.e2ee: Consuming 1 to-device events
quotient.jobs: 200 <- GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: Sent GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: "GetNotificationsJob" destroyed
quotient.jobs: 200 <- GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: "GetNotificationsJob" destroyed
quotient.jobs: Sent POST https://matrix.akselmo.dev/_matrix/client/v3/rooms/%21NenIgaqPaTYiyHsFgQ%3Amatrix.org/read_markers
quotient.jobs: Sent PUT https://matrix.akselmo.dev/_matrix/client/v3/rooms/%21NenIgaqPaTYiyHsFgQ%3Amatrix.org/typing/%40akselmo%3Amatrix.akselmo.dev
quotient.jobs: 200 <- POST https://matrix.akselmo.dev/_matrix/client/v3/rooms/%21NenIgaqPaTYiyHsFgQ%3Amatrix.org/read_markers
quotient.jobs: Sent GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: "SetReadMarkerJob" destroyed
quotient.jobs: 200 <- PUT https://matrix.akselmo.dev/_matrix/client/v3/rooms/%21NenIgaqPaTYiyHsFgQ%3Amatrix.org/typing/%40akselmo%3Amatrix.akselmo.dev
quotient.jobs: "SetTypingJob" destroyed
quotient.jobs: Sent GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: 200 <- GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: "GetNotificationsJob" destroyed
quotient.jobs: 200 <- GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: "GetNotificationsJob" destroyed
quotient.jobs: Sent GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: 200 <- GET https://matrix.akselmo.dev/_matrix/client/v3/notifications
quotient.jobs: "GetNotificationsJob" destroyed

I can't see /sendToDevice logs here, unless those PUT messages are them.

Also, seems when I reached 100 messages, Nheko suddenly gave me a warning that the device (Neochat after 100 messages) is unverified.

from libquotient.

Akselmo avatar Akselmo commented on August 22, 2024

Is the hash empty here and thus nothing happens?

if (hash.isEmpty())

from libquotient.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.