-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Prevent addition overflow #1584
Conversation
A note on the maximum network message size: that size is stored in a length prefix, and only as many bytes can be read from the network in order to form a single inbound message. The implications for deserialization of individual objects are as follows:
The main potential issue I can see (other than the potential overflows that this PR tackles) is pre-allocating too many bytes (if the collection length is stored as a |
Hmm good point! Continuing discussion of this elsewhere, as it ties into how to handle usize/u64/u32 in the codebase which I'll tackle further in a different PR. |
2500e08
to
5239635
Compare
Closing as severely outdated |
Motivation
We should avoid panics, this PR adds checking if additions are allowed in snarkVM. I could not find problematic subtraction cases.
For this, we should agree on the attack surface. I can imagine the following attack vectors:
saturating_add
inserialized_size
. Usingchecked_add
there is tricky as it will change theserialized_size
trait function signature all over the codebase, including in macros and for types which we know have a fixed size.Test Plan
Our usual test suite
Related PRs
Merging into https://github.com/AleoHQ/snarkVM/pull/1499