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

Support for warning users when unknown devices show up #335

Merged
merged 11 commits into from
Feb 2, 2017

Conversation

ara4n
Copy link
Member

@ara4n ara4n commented Jan 21, 2017

This adds a new crypto.DeviceInfo field called known which tracks whether the user has ever been made aware of a device's existence.

If the user tries to send a message into a room with unknown devices present, it throws a custom exception to the app with the details of the devices so the app can warn the user. It also marks the devices as known given the user now knows they exist.

known is implemented as a flag on DeviceInfo rather than part of the verification enum as it's slightly semantically distinct from the concept of whether a device is verified or blocked (although it's questionable as to how a user would be able to verify or block a device without knowing it existed!).

The first draft of this tried to track m.new_device events as they came in, and warn the user if they referred to devices which the user hadn't seen before - however, this felt prone to races between correlating new-devices and room membership, downloading the actual device info, and the user speaking. Hopefully this simpler approach doesn't fall foul of the racing concerns mentioned on the original bug.

Hopefully goes some way towards fixing element-hq/element-web#2143

Twinned with matrix-org/matrix-react-sdk#635.

@ara4n
Copy link
Member Author

ara4n commented Jan 22, 2017

(yes, i know the tests are broken; i've left them as I'm out of time and I'm genuinely not sure what the right way is to handle the fact that i'm deliberately breaking them by legitimately firing the UnknownDeviceException)

@@ -433,6 +472,9 @@ MegolmEncryption.prototype._getDevicesInRoom = function(room) {
// have a list of the user's devices, then we already share an e2e room
// with them, which means that they will have announced any new devices via
// an m.new_device.
//
// XXX: what if the cache is stale, and the user left the room we had in common
// and then added new devices before joining this one? --Matthew
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, this is exactly what element-hq/element-web#2305 (comment) is on about

@richvdh
Copy link
Member

richvdh commented Jan 23, 2017

Looks pretty sane to me. I can try and pick this up and make the tests work once I (finally) finish session import/export.

known is implemented as a flag on DeviceInfo rather than part of the verification enum as it's slightly semantically distinct from the concept of whether a device is verified or blocked (although it's questionable as to how a user would be able to verify or block a device without knowing it existed!).

Yeah, it certainly is. I feel like it's very odd for DeviceInfo.isVerified to be able to return true for an 'unknown' device - I don't know what that even means. Feels like a bad smell to me.

@@ -706,10 +710,16 @@ Crypto.prototype.setDeviceVerification = function(userId, deviceId, verified, bl
verificationStatus = DeviceVerification.UNVERIFIED;
}

if (dev.verified === verificationStatus) {
let knownStatus = dev.known;
if (known !== null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably also check for undefined here

@ara4n
Copy link
Member Author

ara4n commented Jan 23, 2017

DeviceInfo.isVerified returning true for an 'unknown' device means that we haven't told the user that the device exists yet... but it got verified anyway; presumably due to autoverification or cross-signing or similar.

My logic was that: just because known-ness and verification-ness (and blockedness) happen to be orthogonal currently doesn't mean that they should all be put in the same enum (especially one called DeviceVerification. Hence splitting them up into more informative field names. But i agree it can be argued both ways :)

@ara4n
Copy link
Member Author

ara4n commented Jan 23, 2017

also, thanks for picking this up; sorry for leaving it 95% done.

app will have to search for the devices which are pure unverified to warn about them - have to do this from MembersList anyway?
- or megolm could warn which devices are causing the problems.

Why do we wait to establish outbound sessions? It just makes a horrible pause when we first try to send a message... but could otherwise unnecessarily consume resources?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've discussed this before. Because each megolm session consumes 1K of localstorage on every other device in the room. I don't want to add a megolm session to my storage every time someone in #megolm logs in on a new device, and it feels O(N^2)y to start to do so.

We should be more proactive in fetching the device list (this ties into Erik's work there) - and a lot of the work we do (and consequent pause) is in verifying the content of that device list. See element-hq/element-web#2157 (comment) for further thoughts on reducing the pause.

@richvdh
Copy link
Member

richvdh commented Jan 26, 2017

I think we can land this and matrix-org/matrix-react-sdk#635.

@richvdh richvdh assigned ara4n and unassigned richvdh Jan 26, 2017
@richvdh
Copy link
Member

richvdh commented Jan 31, 2017

... or rather, we can land this once we can land matrix-org/matrix-react-sdk#635, which is waiting for a fix to element-hq/element-web#3018

@ara4n ara4n merged commit 2e916e6 into develop Feb 2, 2017
@t3chguy t3chguy deleted the matthew/warn-unknown-devices branch May 10, 2022 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants