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: do not propagate unsigned encrypted messages #5129

Merged

Conversation

AaronFeickert
Copy link
Collaborator

@AaronFeickert AaronFeickert commented Jan 19, 2023

Description

Updates message handling to detect and prevent propagation of unsigned encrypted messages. Minor refactoring for clarity and efficiency. Improves comments.

See this issue for more on banning logic.

Motivation and Context

Encrypted messages must include an encrypted signature that verifies the sender and prevents malleability. Currently, this is only checked after an encrypted message reaches its recipient. If the recipient sees that the message does not include a signature, it will ban its forwarding peer. This is technically correct behavior on the part of the recipient, since either the forwarding peer rendered the message invalid, or itself forwarded a known invalid message. However, the forwarding peer will propagate such an invalid message due to the location of this check; even if it is honest, it will be banned as malicious.

This PR moves the check for the presence of an encrypted signature to the initial verification checks, so it will be caught before being propagated and ensure a ban is performed correctly. It also does some minor refactoring to avoid unnecessary computations, and improves comments.

How Has This Been Tested?

Existing tests pass.

Copy link
Member

@sdbondi sdbondi left a comment

Choose a reason for hiding this comment

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

Thanks LGTM - tested with the memorynet example and everything passed.

@stringhandler stringhandler merged commit d4fe7de into tari-project:development Jan 20, 2023
@AaronFeickert AaronFeickert deleted the message-failure-refactor branch January 20, 2023 15:33
stringhandler pushed a commit that referenced this pull request Jan 31, 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](#5132).

Motivation and Context
---
An [earlier PR](#5123) introduces an error when a peer sends an empty encrypted message, which is not allowed. However, the peer was not banned.

Further, [another PR](#5129) 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?](https://en.wikipedia.org/wiki/Quis_custodiet_ipsos_custodes%3F)
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.

3 participants