ethresearch / p2p

30 stars 0 forks source link

Sybil-like attacks at the p2p level #6

Open nkeywal opened 5 years ago

nkeywal commented 5 years ago

tl;dr: Sybil attacks at the p2p layer are possible on ethv2/sharding. There are multiple ways to mitigate their effects. This post is just there to raise awareness on this subject as a part of the p2p discussions/choices.

On ethereum v1, it's not very interesting for an attacker to add a lot of nodes on the p2p network:

It's a little bit different with sharding:

Some of the possible reasons for such attacks:

I ran a simulation (see here: https://github.com/ConsenSys/wittgenstein/blob/master/src/main/java/net/consensys/wittgenstein/protocol/P2PFlood.java) with 500 real nodes, 4000 byzantine nodes and 13 peers: on average the bloc producers will reach ~280 of the honest nodes out of the 500: graph-4000-4500-13

The easy workaround is to have more peers. With a minimum of 50 peers we reach nearly all honest nodes: graph-4000-4500-50

The impact on the timing is more complicated to estimate. If we consider (it's highly speculative) that we need 500ms to validate a block and we contact the peers one after another, with 300ms per peer we have the graph below. After 8 seconds you reach only 60 honest nodes out of 500. (this with 50 peers min. If you have only 13 peers per node you reach ~15 honest nodes in 8 seconds.) graph-4000-4500-50-300

On the workaround list:

jannikluhn commented 5 years ago

Thank you for this great analysis!

An additional aspect to the workarounds you proposed that we should consider here is peer selection strategy. Today, nodes prefer peers with which they have been connected to for a long time. One could also send new messages to old peers first and only later to newer ones. Then an established network would not be attackable using only newly spun up nodes. Instead, one would have to wait some time for them to built up some reputation and get them higher up in the list, or get connections to nodes that join the network in this preparation phase. So such an attack would at least be a little more costly.

Also, one could try to increase the number of honest nodes per shard by "suggesting" nodes from one shard help out at other shards (this could just be the default, users could of course just turn it off). This would of course mean higher bandwidth (and in later phases maybe also computational) costs. But it would only be necessary in the beginning when the number of nodes is low, which conveniently is probably also a time at which network load is low (ideally the two quantities would be proportional to each other).

nkeywal commented 5 years ago

Instead, one would have to wait some time for them to built up some reputation and get them higher up in the list, or get connections to nodes that join the network in this preparation phase. So such an attack would at least be a little more costly.

I like this idea. It has an advantage as well: if you see thousands of nodes added to a shard all of a sudden, it gives you some time to react. It would have to be implemented carefully however. For example and attacker could have very few nodes but highly connected to build its reputation before turning byzantine. It could also use a single computer with multiple public keys to build multiple reputation scores at the same time before starting the attack with multiple ip address.

I think that the best strategy for a validator, and especially for an attester, will be to connect to a lot of nodes as soon as possible (50 nodes or more given the numbers above). But it has two implications:

Good reputation rules + connecting to a lot of peers may not solve the problem in theory (an attacker could still try to slow down the network to make it miss the slot time deadlines) but could be enough in practice (attack cost high enough for the little benefit).