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

fix(dht/test): ban peers who send empty encrypted messages #5130

Merged
merged 1 commit into from
Jan 31, 2023

Conversation

AaronFeickert
Copy link
Collaborator

@AaronFeickert AaronFeickert commented Jan 20, 2023

Description

Bans peers who send empty encrypted messages. Significantly updates tests to check for more failure modes and assert ban status for each.

Closes issue 5132.

Motivation and Context

An earlier PR introduces an error when a peer sends an empty encrypted message, which is not allowed. However, the peer was not banned.

Further, another PR updates the handling of unsigned encrypted messages to ensure that bans are done correctly, but does not update tests to check for the bug that led to it.

This PR updates the banning logic to ban a peer who forwards an empty encrypted message, which is always detectable.

It also significantly refactors and updates tests. For each relevant high-level message failure mode, we test for proper error detection. We also check for the proper ban status of the forwarding peer.

How Has This Been Tested?

Who tests the testers?

@AaronFeickert
Copy link
Collaborator Author

Interestingly, prior to the earlier fix PR, the MessageSignatureNotProvidedForEncryptedMessage decryption error would never be raised, as it would instead be propagated as a different error.

Copy link
Contributor

@hansieodendaal hansieodendaal left a comment

Choose a reason for hiding this comment

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

Nice addition. Just one comment below.

comms/dht/src/inbound/decryption.rs Outdated Show resolved Hide resolved
@AaronFeickert AaronFeickert marked this pull request as draft January 23, 2023 15:38
@AaronFeickert AaronFeickert changed the title test: ban peers who forward unsigned encrypted messages fix & test: ban peers who send empty messages Jan 23, 2023
@AaronFeickert AaronFeickert changed the title fix & test: ban peers who send empty messages fix(dht/test): ban peers who send empty messages Jan 23, 2023
@AaronFeickert AaronFeickert changed the title fix(dht/test): ban peers who send empty messages fix(dht/test): ban peers who send empty encrypted messages Jan 24, 2023
@AaronFeickert AaronFeickert marked this pull request as ready for review January 25, 2023 17:58
@stringhandler stringhandler merged commit 86a9eaf into tari-project:development Jan 31, 2023
stringhandler pushed a commit to tari-project/rfcs that referenced this pull request Jan 31, 2023
Description
---
Clarifies empty body rules for EnvelopeBody

Motivation and Context
---
In the encrypted case, a valid node should discard a message if the encoded `EnvelopeBody` is zero-sized. A cleartext `EnvelopeBody` may be zero-sized as this is valid proto3 encoding.

Ref tari-project/tari#5130
@AaronFeickert AaronFeickert deleted the ban-test branch January 31, 2023 14:09
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.

Peers aren't banned for forwarding empty encrypted messages
3 participants