earthstar-project / earthstar

Storage for private, distributed, offline-first applications.
https://earthstar-project.org
GNU Lesser General Public License v3.0
641 stars 20 forks source link

Address private set intersection exploit #318

Open sgwilym opened 1 year ago

sgwilym commented 1 year ago

What's the problem you want solved?

When two peer sync, they send each other a DISCLOSE message:

/** An event for disclosing which shares a Peer has without actually revealing them. Another peer can use the salt to hash their own shares' addresses and see if they match. */
export type SyncerDiscloseEvent = {
  kind: "DISCLOSE";
  syncerId: string;
  salt: string;
  shares: string[];
  formats: string[];
  canRespond: boolean;
};

While this does not reveal the share addresses, it seems like there's a way for a malicious peer to trick a peer into thinking they both have the same shares: simply mirroring the honest peer's disclose message back at them.

The honest peer would then assume the other peer has all the same shares in common, and would proceed to send sync messages potentially containing share addresses to the malicious peer.

This problem domain is called private set intersection.

Is there a solution you'd like to recommend?

sgwilym commented 1 year ago

Additionally, we should probably not have share addresses in sync messages. Rather we should refer to the shares by the salted hash that was sent at the beginning of sync. But that is a breaking change.

AljoschaMeyer commented 1 year ago

The canonic solution for rather small sets is Huberman, Bernardo A., Matt Franklin, and Tad Hogg. "Enhancing privacy and trust in electronic communities." Proceedings of the 1st ACM conference on Electronic commerce. 1999.; for a very succinct summary see here, for a more accessible summary see here. Before using or implementing, ask someone who actually knows their crypto, i.e., not me.

For a fairly recent and accessible, high-level introduction to private set intersection, see this presentation.