-
Notifications
You must be signed in to change notification settings - Fork 256
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
Decoding BigUInt
causes unbound allocation
#839
Comments
Is You found this fuzzing code we envision deploying? If unused, we could maybe deactivate Ideally, arkworks could migrate to |
I think most code uses Afaik, all those usages should all be ephemeral, meaning |
I did not see it exposed directly in types that i wanted to use, but also did not check everything. |
Decoding a
BigUint
internally decodes aVec<u8>
here:algebra/serialize/src/impls.rs
Line 176 in 2ad2d84
which then in turn calls
Vec::with_capacity
with the decoded length:algebra/serialize/src/impls.rs
Line 523 in 2ad2d84
This can cause a panic if that value is unreasonable large.
A possible test vectors:
Honestly, i am not sure if this is even efficiently fixable. I have the same issue in another generic decoding library, and we are currently trying to have a special
DecodeWithMemLimit
kind of thing, that limits total allocations of a decode call.The trivial approach of just checking
len
does not work, since types can be recursive. Nested vectors will inevitably overflow any artificial restriction.Not sure what to do on untrusted input for production software, i would probably isolate the decoding into a separate process.
The text was updated successfully, but these errors were encountered: