-
Notifications
You must be signed in to change notification settings - Fork 276
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
roaring_bitmap_portable_deserialize_safe avoids overflows during deserialization but it does not validate the input #324
Comments
@K2 Does the data come from a valid bitmap? The Validating the input is more expensive. We do not currently do this tasks. I will retitle the issue. |
The documentation is as follows: /**
* read a bitmap from a serialized version in a safe manner (reading up to maxbytes).
* This is meant to be compatible with
* the Java and Go versions. See format specification at
* https://github.com/RoaringBitmap/RoaringFormatSpec
* In case of failure, a null pointer is returned.
*/
roaring_bitmap_t *roaring_bitmap_portable_deserialize_safe(const char *buf, size_t maxbytes); It does not validate the input. |
What would make a sensible test case if were to enroll into oss-fuz then? |
@K2 So the expectation currently is that you are pointing a data you serialized. You certainly can create adversarial content, as your code demonstrate. To validate, we need to scan the content of the container, and check that they could have been produced from valid roaring bitmaps:
There might be other constraints that I do not have in mind right now. We do not do this. It certainly doable, but it is not something we offer right now. |
It is not that it is not valid, it is that we do not support this kind of validation currently. (To be clear, we could do it and I plan to leave this issue open.) The way the Java and Go versions do fuzzing... is... let me offer pointers... |
(Your fuzzing is good, let me be clear.) |
Then perhaps to minimize the testroaring_bitmap_portable_deserialize_safe for now and update the test case in the future as we add more validation? |
At a glance, the Go deserialization fuzzer checks that there is no panic while deserialization... So basically, you throw anything at However, the bulk of the fuzzer is based on random operations on both a bitset and a roaring bitmap, and testing that the results agree: |
@richardstartin Did something similar in Java... That is, you take a bitset (or another set data structure) and a roaring bitmap, and then you mutate both in a semantically equivalent manner, then you check that the results are semantically equivalent... and so forth. |
Right. So just testing |
Consider that we have no fuzzing right now. Whatever you provide is a likely a win. |
(It would be nice to have a fully validating deserializer. Arguably, it would be easier to build with a good test framework.) |
Does a fully validating deserializer exist today? |
It does not! Pull request invited! (It is not super hard.) |
Related to this, just raised this #486 to provide also roaring_bitmap_deserialize_safe for the CRoaring format |
Believe we're now able to say that deserialize_safe + internal_validate acts as a validating deserializer since #675 |
Closing. |
Testcase for attached crash. Build with ASAN & ASAN CRoaring.
crash.zip
The text was updated successfully, but these errors were encountered: