ipfs / go-bitswap

The golang implementation of the bitswap protocol
MIT License
216 stars 112 forks source link

Implement ReputationManager #581

Closed synzhu closed 1 year ago

synzhu commented 2 years ago

closes https://github.com/ipfs/go-bitswap/issues/577

synzhu commented 2 years ago

I don't see what this is trying to solve, is the client code particularly more attackable ?

The issue right here is that I can send you either:

  • A really big wantlist updates that will hit the server and ignore this code.
  • Garbage protobuf data (protobuf will ignore fields it doesn't know, you aren't checking for this).

I guess your code would only protect if there is some costy operation in the client code, there is also in the server.

In the server, it's not really possible to tell whether the wantlist updates are legit or not, right? As for the garbage protobuf data, I actually looked into this, but with the current version of Protobuf that is being used it doesn't seem like it's possible to check garbage data: https://github.com/protocolbuffers/protobuf/issues/272. However if you know a way to do it, please let me know and I'm happy to add it.

@Jorropo

Stebalien commented 2 years ago

I think this is a "one step at a time" kind of thing.

Jorropo commented 2 years ago

@Stebalien IMO whatever this is trying to do, it's not effective, I don't want more complex code that isn't usefull.

One step at a time seems fine, however I havn't seen anyone who claims to be commited to solve the other issues.

synzhu commented 2 years ago

@Jorropo By allowing Score Keeper to be implemented by the application, the application can do things like block / disconnect from peers whose score falls below a certain threshold, based on the amount of unwanted data they have sent us.

Do you have suggestions on how to mitigate this problem in a different way?

Jorropo commented 2 years ago

By allowing Score Keeper to be implemented by the application, the application can do things like block / disconnect from peers whose score falls below a certain threshold, based on the amount of unwanted data they have sent us.

This isn't what it is doing, it's based on the amount of unwanted blocks. There is a problem: a node can send you lots of unwanted data. And your solution: blocking nodes that send you too much bad blocks doesn't solve this problem, it solve only one vector there is multiple other vectors.

Your current solution doesn't solve the problem and so is useless, however if you also solve other unwanted data vectors this would be good. Going by small steps can make sense, but if you don't have a plan to solve the real problem I don't feel like we should merge this (who wants to maintain code that doesn't solve anything ?).

An othre possibility is that maybe sending lots of extra blocks is particularly more effective as an attack vector compared to other vectors, then this could make sense, however you would need to prove this is actually a problem (just write a script that sends a bunch of unwanted block to a node and profile it to see if it's particularly bad).

synzhu commented 2 years ago

@Jorropo added follow up discussion to https://github.com/ipfs/go-bitswap/issues/577

Jorropo commented 1 year ago

This repository has been moved to https://github.com/ipfs/go-libipfs. There is not an easy way to transfer PRs, so if you would like to continue with this PR then please re-open it in the new repository and link to this PR.