-
-
Notifications
You must be signed in to change notification settings - Fork 802
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
Audit for use of size_hint coming from untrusted data #744
Comments
See rust-lang-deprecated/rustc-serialize#150 for some similar discussion. |
we can never protect against oom. If enough data comes from a stream, we will end up allocating too much memory at some point. |
do bincode and similar check whether the number of hinted elements is also the number of deserialized elements? Otherwise another attack is to always suggest 4096 elements (or whatever the limit is), and only deserialize one element. Since the allocations are never shrunk, we waste a lot of memory. |
Bincode can only succeed if 4096 elements were deserialised in that case. |
Let's continue to track this under #850. |
@nox pointed out in IRC that Bincode sequence and map deserializers provide a size_hint that comes straight from the input, and untrusted Bincode data could put a fake large number there. If a Deserialize type takes that hint and uses it for Vec::with_capacity, it could be bad.
Let's look through existing formats to see how prevalent this is and try to come up with guidelines for avoiding this problem.
The text was updated successfully, but these errors were encountered: