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

ssz: fix buffer overflows, explicit error reporting #7

Merged
merged 2 commits into from
Oct 8, 2018

Conversation

arnetheduck
Copy link
Member

  • fix buffer overflow in seq reading
  • report errors explicitly - overflows when reading byte buffers are expected

Copy link
Contributor

@mratsim mratsim left a comment

Choose a reason for hiding this comment

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

LGTM, actually that's one part of the spec that is not covered at the moment.

@arnetheduck
Copy link
Member Author

How do you mean, not covered? Given the fixed code above, it's clear that the format gives enough data to implement safe parsing - all lengths are known ahead of reading the data - either from schema or explicit in the data stream, meaning there's no case where you have to keep reading an unknown amount of bytes that might lead to trouble

@mratsim
Copy link
Contributor

mratsim commented Oct 5, 2018

Not covered in the sense what if we get malformatted data how to handle that gracefully.

@arnetheduck
Copy link
Member Author

malformatted

drop it completely? there's really nothing else you can do. this is not a self-healing format, nor do I think it should be..

@mratsim
Copy link
Contributor

mratsim commented Oct 5, 2018

Yeah of course, but at a higher level, do we continue silently, ask for new data, slash a stake, nuke a shard chain?

@arnetheduck
Copy link
Member Author

Well, it's treated the same way as if the serialized data wasn't sent at all - it's equivalent from the higher level perspective - in fact, it's likely that if ever a client sends malformed data, that client should simply be dropped.

@mkalinin
Copy link

mkalinin commented Oct 6, 2018

I agree with @arnetheduck. Any peer that sent malformed data once will likely do that again, cause it's either buggy or malicious. Thus, it should be immediately dropped. I don't think it will be useful to add any recommendations like that to SSZ spec or to any other spec. It looks more like an implementers decision what to do in each particular case (maybe some network monitor would like to collect statistics of malicious/buggy peers).

@mratsim mratsim merged commit 577598c into master Oct 8, 2018
@mratsim mratsim mentioned this pull request Nov 8, 2018
@arnetheduck arnetheduck deleted the ssz-fix-overflow branch November 8, 2018 15:22
@dryajov dryajov mentioned this pull request Apr 12, 2021
etan-status pushed a commit that referenced this pull request May 12, 2022
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