vacp2p / research

Thinking in code
MIT License
62 stars 4 forks source link

Simple Waku Relay DoS mitigation #164

Closed kaiserd closed 10 months ago

kaiserd commented 1 year ago

This issue is part of SeM secure scaling and tracks the work on (a) simple Waku Relay DoS mitigation technique(s), which are necessary for the scaling Status to 1 mio users.

actions

more info / related

alrevuelta commented 1 year ago

Some discussions around this were started here: https://github.com/vacp2p/research/issues/148. Linking it here.

alrevuelta commented 1 year ago

Quick summary of our meeting(s), regarding simple DoS mitigation for the current MVP (< 6 months)

DoS protection can be archived at two different levels:

So the solution to DoS is a mix of both levels. Some application-level identifiers, that allow us to i) prevent sybils and ii) rate limit existing nodes, and some validation built in at the protocol level that allows us to enforce some rules using the said identifiers.

The main questions are: where are these identities taken from, and how are they used to avoid DoSing the network. The where sets the entry barrier to waku and the how sets nodes requirements in terms on bandwidth.

We currently have 3 ideas on "simple" DoS mitigation techniques. All of them implement message validation in different ways on a gossipsub level, an already exposed interface by libp2p using addValidator, that allows to Accept, Ignore or Reject messages given some criteria. These are the ideas we have, ordered by complexity (low to high). Note that they can be considered incremental steps to reach the latest one.

LNSD commented 1 year ago

The PR #1537 was merged before I could perform any code review. The merged code has deficiencies that need to be addressed as soon as possible:

The Waku message integrity validator is only being applied to the default pub-sub topics (here) since the validator is only applied at the WakuRelay instance creation.

If any user subscribes to a pub-sub topic via the subscribe API (here) (e.g., via the JSON-RPC API), the message integrity validator won't be added to that topic, leaving those topics out of the claimed "DoS protection".

Additionally, the message protobuf integrity validator uses the waku_message's decode function that deserializes the protobuf fields. The validation approach is inefficient (and potentially problematic) because the function performs a series of allocations due to the deserialization process. As they are executed on every message's arrival, validators must be fast and efficient to not impact the message latency and overall system performance.

LNSD commented 1 year ago

@alrevuelta @jm-clius I am working on enhancing the Waku Relay implementation as part of the Message UID initiative. I am taking over the Waku Relay's message validation and will address the deficiencies introduced in #1537.

rymnc commented 1 year ago

Hey @alrevuelta, adding this document(semaphore for community-level message validation) which may be of relevance to this thread.

LNSD commented 1 year ago

Remember that the Message Unique ID ADR also adds a message integrity check to the Waku Relay protocol: https://github.com/waku-org/pm/issues/9

fryorcraken commented 10 months ago

@alrevuelta can this be closed?

alrevuelta commented 10 months ago

@fryorcraken Yes, closing it. The deliverable of this was the opt-in dos protection designed ad-hoc for status (note that its not meant to be used by the waku network)