-
Notifications
You must be signed in to change notification settings - Fork 24
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
[bug] Treemath isn't sound #173
Comments
Thanks for submitting! We will take a look |
Thanks @OtaK for finding the bug! Maybe a better solution than making all operations checked would be to set a reasonable upper bound on the leaf / node indices, for example 2^28? I don't think MLS can actually deal with groups that large. For example just 2^31 X25519 public keys is almost 70GB of data. mls-rs would load this to RAM which wouldn't work (unless you have a cluster). I guess groups that huge would require a specialized implementation. |
Hi @mulmarta! Sorry for the late reply. Fixing the treemath to be checked/saturating would probably do the right thing. I don't remember if the epoch math is sound, but from experience, something as simple as reaching I really think fixing all the math once and for all is the right approach so that all of these can be left behind 🎉 |
Hi folks,
I was playing around a bit with fuzzing and I found some cases where the unchecked treemath present pretty much everywhere might cause some sneaky bugs, particularily in the
Group::process_incoming_message()
entrypoint;For example, the following backtrace is caused by this very line:
Obviously, the crashes do not happen when ran with
--release
but instead the overflowing multiplication would wrap, which would cause wrong indexes being calculated (i.e. aLeafIndex
=(u32::MAX / 2 + 1) * 2
would give aNodeIndex
=1
) and cause things like signature verification errors, weird behaviors, and basically indexing bugs everywhere.After looking a bit everywhere where there is treemath involved, it seems there's a lot of unchecked math being used, especially where appropriate - index calculations through additions/multiplications/subtractions/left shifts - and should be using
[checked|saturating]_[op]
.I could make a (big) PR fixing all of those if you'd like, but that would cause quite some internal API breakage (
checked_mul
returns anOption<T>
for example).I added some fuzz inputs that cause those issues in the
processbytes_test.zip
file. You can run them usingcargo fuzz run process_bytes crash-[hash]
.Feel free to ask for more details; Keep in mind that this isn't a security issue but rather a functional bug - this doesn't compromise the security properties of MLS but rather mls-rs's functionality on large groups.
processbytes_test.zip
The text was updated successfully, but these errors were encountered: