Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

retrieve: block unsolicited chunk deliveries #1875

Merged
merged 10 commits into from
Oct 21, 2019
Merged

Conversation

acud
Copy link
Member

@acud acud commented Oct 11, 2019

This PR adds a Ruid to the retrieve protocol messages in order to block unsolicited chunk deliveries (which is an attack vector on several swarm properties)

fixes #1800

@acud acud force-pushed the retrieve-block-unsolicited branch 3 times, most recently from 2dfbae7 to b5c9e56 Compare October 13, 2019 03:34
@acud acud changed the title retrieve: add ruid to retrieve request retrieve: block unsolicited chunk deliveries Oct 13, 2019
@acud acud force-pushed the retrieve-block-unsolicited branch from b5c9e56 to 5959975 Compare October 13, 2019 06:56
network/retrieval/peer.go Outdated Show resolved Hide resolved
network/retrieval/retrieve_test.go Outdated Show resolved Hide resolved
network/retrieval/retrieve_test.go Outdated Show resolved Hide resolved
network/retrieval/retrieve_test.go Outdated Show resolved Hide resolved
network/retrieval/peer.go Outdated Show resolved Hide resolved
network/retrieval/peer.go Outdated Show resolved Hide resolved
network/retrieval/peer.go Show resolved Hide resolved
network/retrieval/retrieve_test.go Show resolved Hide resolved
Copy link
Member

@janos janos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for addressing my comments.

network/retrieval/peer.go Show resolved Hide resolved
@janos
Copy link
Member

janos commented Oct 15, 2019

@acud some of network tests are failing, probably because of the new protocol version.

Copy link
Contributor

@mortelli mortelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great.

other than:

  • rebasing/merging with master
  • making the tests pass

i have only very minor comments.

network/retrieval/peer.go Show resolved Hide resolved
network/retrieval/peer.go Outdated Show resolved Hide resolved
network/retrieval/peer.go Outdated Show resolved Hide resolved
network/retrieval/retrieve.go Outdated Show resolved Hide resolved
simulation/examples/cluster/cluster_test.go Show resolved Hide resolved
network/retrieval/retrieve_test.go Show resolved Hide resolved
@mortelli
Copy link
Contributor

tagging @janos for this question as well:

is it impossible for a node to request 2 chunks from the same address parallelly enough so that both requests are sent out before a chunk delivery message arrives for any one of them?

@janos
Copy link
Member

janos commented Oct 15, 2019

tagging @janos for this question as well:

is it impossible for a node to request 2 chunks from the same address parallelly enough so that both requests are sent out before a chunk delivery message arrives for any one of them?

@mortelli yes, it is possible. Retrieval protocol is handling messages asynchronously.

@mortelli
Copy link
Contributor

tagging @janos for this question as well:
is it impossible for a node to request 2 chunks from the same address parallelly enough so that both requests are sent out before a chunk delivery message arrives for any one of them?

@mortelli yes, it is possible. Retrieval protocol is handling messages asynchronously.

Thanks.

While we're at it... what does ruid really mean? is it short for request ID?

@janos
Copy link
Member

janos commented Oct 15, 2019

While we're at it... what does ruid really mean? is it short for request ID?

Yes, that is correct, request (or retrieval) unique id. There is no check for uniqueness, but for short lived requests as we have here, random int32 would be fine, I suppose.

@acud
Copy link
Member Author

acud commented Oct 16, 2019

@acud some of network tests are failing, probably because of the new protocol version.

why on earth do we have tests that depend on the protocol version.........

Copy link
Contributor

@Eknir Eknir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left two comments about security.

  1. How random is the random number?
  2. Is there a possibility of sniffing on outgoing messages from a peer and thus figuring out his current outstanding requests.

It is important that this is absolutely watertight, as the rewards from hacking this is up to the total liquid balance currently outstanding in the network => high.

err = protoPeer.Send(ctx, ret)
if err != nil {
protoPeer.logger.Error("error sending retrieve request to peer", "err", err)
protoPeer.logger.Error("error sending retrieve request to peer", "ruid", ret.Ruid, "err", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you ok with logging and returning the error here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, if i don't log the error here i lose the context of the peer address which is appended to the log line (since we are using the peer logger here)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that I am a bit late, but we should use error annotations instead both logging them and returning to the caller.

Copy link
Contributor

@Eknir Eknir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for this work!
Some minor outstanding comments still--please consider them, but definitely not a blocker/

@acud acud merged commit 3f0998d into master Oct 21, 2019
@acud acud deleted the retrieve-block-unsolicited branch October 21, 2019 08:43
@acud acud added this to the 0.5.3 milestone Nov 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unsolicited chunk delivery causing possibility to drain any chequebook
5 participants