diff options
author | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-03-09 14:12:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-09 14:12:28 +0100 |
commit | 3cf68a084ea5bff20129222867a399b05e6e0bd6 (patch) | |
tree | 28a865023492740f1e14320eb187394507b8cfa6 /lib/connection.cpp | |
parent | 66918a4c7d393a8b22de7bf23009651dbd919366 (diff) | |
parent | cc7056851f92ba5b6224b5b82413ec55fd6aaa7f (diff) | |
download | libquotient-3cf68a084ea5bff20129222867a399b05e6e0bd6.tar.gz libquotient-3cf68a084ea5bff20129222867a399b05e6e0bd6.zip |
Merge #542: Guard against device reuse attacks
Diffstat (limited to 'lib/connection.cpp')
-rw-r--r-- | lib/connection.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp index 4abb77a5..ae8532c3 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -1998,6 +1998,7 @@ void Connection::Private::loadOutdatedUserDevices() currentQueryKeysJob = nullptr; const auto data = queryKeysJob->deviceKeys(); for(const auto &[user, keys] : asKeyValueRange(data)) { + QHash<QString, Quotient::DeviceKeys> oldDevices = deviceKeys[user]; deviceKeys[user].clear(); for(const auto &device : keys) { if(device.userId != user) { @@ -2019,6 +2020,12 @@ void Connection::Private::loadOutdatedUserDevices() "Skipping this device"; continue; } + if (oldDevices.contains(device.deviceId)) { + if (oldDevices[device.deviceId].keys["ed25519:" % device.deviceId] != device.keys["ed25519:" % device.deviceId]) { + qCDebug(E2EE) << "Device reuse detected. Skipping this device"; + continue; + } + } deviceKeys[user][device.deviceId] = device; } outdatedUsers -= user; |