Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add 1MB restriction to LightPush and Relay #1351

Merged
merged 14 commits into from
May 17, 2023
Merged

feat: add 1MB restriction to LightPush and Relay #1351

merged 14 commits into from
May 17, 2023

Conversation

weboko
Copy link
Collaborator

@weboko weboko commented May 12, 2023

Problem

Users can abuse network and send huge messages.

Solution

Add same filter as in other implementations.

Notes

@weboko weboko requested a review from fryorcraken as a code owner May 12, 2023 23:43
@weboko
Copy link
Collaborator Author

weboko commented May 12, 2023

As next iteration I think we can split huge messages and send in chunks. Once chunks received we can figure out how to identify them and merge.

@github-actions
Copy link

github-actions bot commented May 12, 2023

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
Waku core 28.94 KB (+0.37% 🔺) 579 ms (+0.37% 🔺) 2.4 s (+22.93% 🔺) 3 s
Waku default setup 313.75 KB (+0.15% 🔺) 6.3 s (+0.15% 🔺) 7.9 s (+7.38% 🔺) 14.2 s
ECIES encryption 28.09 KB (0%) 562 ms (0%) 1.6 s (+2.64% 🔺) 2.2 s
Symmetric encryption 28.09 KB (0%) 562 ms (0%) 2 s (+63.33% 🔺) 2.6 s
DNS discovery 108.25 KB (0%) 2.2 s (0%) 3.9 s (+14.37% 🔺) 6 s
Privacy preserving protocols 132.25 KB (+0.17% 🔺) 2.7 s (+0.17% 🔺) 4.7 s (+18.47% 🔺) 7.4 s
Light protocols 29.8 KB (+0.58% 🔺) 597 ms (+0.58% 🔺) 2.2 s (+16.74% 🔺) 2.8 s
History retrieval protocols 29.53 KB (+0.35% 🔺) 591 ms (+0.35% 🔺) 2.1 s (+39.86% 🔺) 2.7 s
Deterministic Message Hashing 5.78 KB (0%) 116 ms (0%) 1.1 s (+66.22% 🔺) 1.2 s

@fryorcraken
Copy link
Collaborator

I would only apply the fix on relay and leave the responsibilty to the remote peer to decline messages over 1MB coming from light push. WDYT @alrevuelta ?

That would allow the size limit for relay to be moved to the relay package as it's related to relay domain.

Also I would not provide out of the box message splitting as I think different needs for large messages may require different strategies.

@alrevuelta
Copy link

I would only apply the fix on relay and leave the responsibilty to the remote peer to decline messages over 1MB coming from light push. WDYT @alrevuelta ?

So you mean that you would just enforce this limit on the receiver side and not sender? If so, I think this limit (and later on a lower one imho) should be enforced on both sides. So a message bigger than x is not published by the publisher and not gossiped by the subscriber.

@fryorcraken
Copy link
Collaborator

I would only apply the fix on relay and leave the responsibilty to the remote peer to decline messages over 1MB coming from light push. WDYT @alrevuelta ?

So you mean that you would just enforce this limit on the receiver side and not sender? If so, I think this limit (and later on a lower one imho) should be enforced on both sides. So a message bigger than x is not published by the publisher and not gossiped by the subscriber.

I am saying that we should only enforce this limit on the Waku Relay protocol and not the Waku Light Push protocol.

When you say "Publisher", are you referring to a Relay publisher or Light Push requester? or both?

@alrevuelta
Copy link

I am saying that we should only enforce this limit on the Waku Relay protocol and not the Waku Light Push protocol.

When you say "Publisher", are you referring to a Relay publisher or Light Push requester? or both?

I would enforce the 1mb limit in both, unless you have any strong reason for not doing it. I mean, if the network is going to reject it, why allowing >1mb in lightpush?

@@ -49,6 +50,11 @@ class LightPush extends BaseProtocol implements ILightPush {
const recipients: PeerId[] = [];

try {
if (!isSizeValid(message.payload)) {
log("Failed to send waku light push: message is bigger that 1MB");
return { recipients };
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want to start return errors in this result?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, good point. I'd still rather not throw, as hybrid let's put error codes there.

@weboko weboko merged commit 72f97d4 into master May 17, 2023
@weboko weboko deleted the weoko/1mb branch May 17, 2023 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: reject 1MB and above messages
3 participants