-
Notifications
You must be signed in to change notification settings - Fork 285
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 parsing EOF version in header #957
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #957 +/- ##
=======================================
Coverage 94.29% 94.30%
=======================================
Files 143 143
Lines 16138 16142 +4
=======================================
+ Hits 15218 15222 +4
Misses 920 920
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Can we have a test for this? |
In theory we have: https://github.com/ethereum/evmone/blob/master/test/unittests/eof_validation_test.cpp#L38 |
I'd love to know more what's going on here (or have a test or some other guarantee this never materializes). How did the fuzzer manage to run into this? |
I think I know how to fix the tests so I will submit it separately. When you use vector or string as the container the out-of-bounds read is not always detected because of the container's additional capacity: this memory is actually allocated and it is merely the out-of-bounds by the vector/string logic. In the string case, there is always the terminating null byte allocated in the container. Normally, address sanitizer misses this unless the container has special annotations for address sanitizer. Availability of these annotations depends on the stdlib vendor and version. We may not have it in CI. See https://github.com/google/sanitizers/wiki/AddressSanitizerContainerOverflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation, this is pure magic... Though how did the fuzzer run into this?
It allocates the input buffer of exact size. |
Do not merge yet. |
This is the older PR where we use libc++ with address sanitizer. There you can see some container-overflows reported in the |
In EOF validation tests, move the container to new heap-allocated buffer of exact size to easily find out-of-buffer reads with address sanitizer.
This helps: #958. |
Fixes the bug introduced in #947 where reading the version byte is missing the bounds check.
141648a
to
1d357c2
Compare
Fixes the bug introduced in #947 where reading the version byte is missing the bounds check.
This bug is hard to detect when
std::string
is used as the test container. Found by a fuzzer.