-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Remote completion on untrusted devices is incorrect #7533
Description
Reported in https://forum.syncthing.net/t/remote-device-status-on-encrypted-end/16577
The version vector on an encrypted file info has it's counter set to now whenever it's sent:
// The vector is set to something that is higher than any other version sent
// previously, assuming people's clocks are correct. We do this because
// there is no way for the insecure device on the other end to do proper
// conflict resolution, so they will simply accept and keep whatever is the
// latest version they see. The secure devices will decrypt the real
// FileInfo, see the real Version, and act appropriately regardless of what
// this fake version happens to be.
version := Vector{
Counters: []Counter{
{
ID: 1,
Value: uint64(time.Now().UnixNano()),
},
},
}
That means if two devices are connected to an untrusted device, the second device sending an identical file-info, will send it with a newer version. Thus to the untrusted device the first device looks out of sync. The first device, having de-crypted the version, doesn't care.
Synchronisation still works fine, even if multiple untrusted devices are involved. It just causes a few unnecessary index sends. For the remote status I see three options:
- Just don't display the status of remotes on untrusted nodes.
- Don't encrypt version vectors.
- Devise some scheme to get consistent encrypted/fake versions on all devices and that still is correctly ordered from the point of view of the untrusted device (e.g. just hashing won't do).
An option for 3. would be to keep using id 1, together with the maximum of all counter values in the plain vector (haven't thought much about possible corner cases yet :) ). However I am currently not sure it's worth encrypting the version at all: An untrusted node can already obtain the information about who/when files are modified, by observing from whom and when it receives index updates. That's not always possible (e.g. when receiving indexes indirectly, i.e. not from the device that changed the file) and less precise than having all the counters. Still I am not sure knowing who edited a file and when is sensitive information within our threat model. And the less difference there is between an encrypted file info and a plain one, the less issues like this will crop up with the implementation approach taken (untrusted devices work almost the same as any other device).