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 discovery exception handling #1160

Merged
merged 4 commits into from
Aug 22, 2018
Merged

Fix discovery exception handling #1160

merged 4 commits into from
Aug 22, 2018

Conversation

mkalinin
Copy link
Contributor

@mkalinin mkalinin commented Aug 20, 2018

Fixes UDPListener crash caused by malformed nodeId received from malicious peers.

@zilm13
Copy link
Collaborator

zilm13 commented Aug 20, 2018

I think you should disconnect it in case of error anyway, should you?

@coveralls
Copy link

coveralls commented Aug 20, 2018

Coverage Status

Coverage decreased (-0.007%) to 56.116% when pulling 8ee599b on fix/discovery-exceptions into ec3ce8f on develop.

@mkalinin
Copy link
Contributor Author

@zilm13

I think you should disconnect it in case of error anyway, should you?

UDP is connectionless protocol, thus there is no session that can be closed.

@mkalinin
Copy link
Contributor Author

mkalinin commented Aug 21, 2018

Thanks a lot to @JMdoubleU for pointing to that problem!

try {
nodeManager.handleInbound(event);
} catch (Throwable t) {
logger.error("Failed to process incoming message: {}", event.getMessage(), t);
Copy link
Member

Choose a reason for hiding this comment

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

I would change log level to WARN or even INFO, since we can receive any garbage and this is not our error.
I'd also output t.toString() instead of t to not flood logs with traces in case of invalid messages

Ideally we can also try to differentiate the message handle problems onto MalformedMessageException and others. The first one is not error, the second one should be assumed as our error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Decided to reduce logging level for the beginning. MalformedMessageException requires much more changes in the codebase.

@zilm13
Copy link
Collaborator

zilm13 commented Aug 21, 2018

@mkalinin

UDP is connectionless protocol, thus there is no session that can be closed.

oops, forgot that discovery works on UDP

Copy link
Collaborator

@zilm13 zilm13 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 to me

@mkalinin mkalinin merged commit fa26723 into develop Aug 22, 2018
@mkalinin mkalinin added this to the 1.9.0-Constantinople milestone Aug 22, 2018
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.

5 participants