visitor-flutter icon indicating copy to clipboard operation
visitor-flutter copied to clipboard

Feed resyncing bugs

Open boreq opened this issue 2 years ago • 0 comments

This bug report involves two separate mechanisms present in go-ssb:

  1. The first mechanism is the Authorizer. By default authorizer is implemented by lister. The authorizer can be replaced by specifying the option WithPublicAuthorizer.
  2. The second mechanism is the mechanism responsible for resyncing the local feed in case of data loss. This mechanism is triggered only if the authorizer returns an error and there are no feeds stored.

I identified two bugs in this mechanism.

First bug:

  1. A user replaces the authorizer with an implementation which always returns nil in order to allow connections from all peers. This can be done using the aforementioned option.
  2. The function will return right away.
  3. The code responsible for resyncing the feed will not be triggered.

This bug is a result of the code relying on an undocumented side effect.

Second bug:

  1. Local feed sync process is started.
  2. The peer doesn't have all messages or the connection terminates early.
  3. The local feed will be partially replicated.
  4. The resync process will not be attempted again as now at least one feed may be present locally.

A simple fix that I attempted to fix both of those problems involved always replicating the local feed and can be found here https://github.com/boreq/ssb/commit/0e21439081f3b107bb21e9fc98ef3d7e8d108ced. Unfortunately this is not a correct fix as this will not work for people using the default authorizer. It accidentally works only because in my case an authorizer which returns nil was used.

To fix this code correctly I suspect that the authorizer should instead operate on some different level. Instead of authorizing connections it could authorize which blobs or feeds someone can retrieve. It could then always allow to establish a connection and replicate your own feed while limiting replication of other feeds. With the authoriser mechanism implemented as it is now I don't really see how to fix those problems for all users.

boreq avatar Mar 29 '22 13:03 boreq