Skip to content
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

deserialize: prevent unbound allocation #129

Merged
merged 1 commit into from
Feb 14, 2023
Merged

deserialize: prevent unbound allocation #129

merged 1 commit into from
Feb 14, 2023

Conversation

mina86
Copy link
Contributor

@mina86 mina86 commented Feb 13, 2023

With a crafted input, a malformed data of just four bytes may lead to
allocation of 4 GiB. This may lead to OOM on constrained environments
(e.g. inside of a container with memory limits set or on 32-bit
machines).

(This once again shows Rust desperately needs full specialisation. We
may dream of time that it ever comes…)

With a crafted input, a malformed data of just four bytes may lead to
allocation of 4 GiB.  This may lead to OOM on constrained environments
(e.g. inside of a container with memory limits set or on 32-bit
machines).

(This once again shows Rust desperately needs full specialisation.  We
may dream of time that it ever comes…)
@mina86 mina86 requested a review from frol as a code owner February 13, 2023 16:46
@mina86
Copy link
Contributor Author

mina86 commented Feb 13, 2023

See also near/nearcore#8562

Copy link
Collaborator

@frol frol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mina86 Thanks for the fix!

@frol frol merged commit d431291 into near:master Feb 14, 2023
@mina86 mina86 deleted the a branch February 21, 2023 10:24
mina86 added a commit to mina86/nearcore that referenced this pull request Feb 21, 2023
This is re-application of commit b8196b1 with the same subject alas
this time borsh is updated to 0.10.2.  Previous attempt to update the
dependency was reverted becauses of potential DOS which was addressed
in borsh 0.10.2 (see <near/borsh-rs#129>).

Like before, the update is mostly just a matter of replacing deserialize
function in BorshDeserialize implementation by deserialize_reader.  In
a few of existing custom implementations for (de)serialization could be
removed alltogether.
mina86 added a commit to mina86/nearcore that referenced this pull request Feb 21, 2023
This is re-application of commit b8196b1 with the same subject alas
this time borsh is updated to 0.10.2.  Previous attempt to update the
dependency was reverted becauses of potential DOS which was addressed
in borsh 0.10.2 (see <near/borsh-rs#129>).

Like before, the update is mostly just a matter of replacing deserialize
function in BorshDeserialize implementation by deserialize_reader.  In
a few of existing custom implementations for (de)serialization could be
removed alltogether.
mina86 added a commit to mina86/nearcore that referenced this pull request Feb 21, 2023
This is re-application of commit b8196b1 with the same subject alas
this time borsh is updated to 0.10.2.  Previous attempt to update the
dependency was reverted becauses of potential DOS which was addressed
in borsh 0.10.2 (see <near/borsh-rs#129>).

Like before, the update is mostly just a matter of replacing deserialize
function in BorshDeserialize implementation by deserialize_reader.  In
a few of existing custom implementations for (de)serialization could be
removed alltogether.
mina86 added a commit to mina86/nearcore that referenced this pull request Feb 21, 2023
This is re-application of commit b8196b1 with the same subject alas
this time borsh is updated to 0.10.2.  Previous attempt to update the
dependency was reverted becauses of potential DOS which was addressed
in borsh 0.10.2 (see <near/borsh-rs#129>).

Like before, the update is mostly just a matter of replacing deserialize
function in BorshDeserialize implementation by deserialize_reader.  In
a few of existing custom implementations for (de)serialization could be
removed alltogether.
mina86 added a commit to mina86/nearcore that referenced this pull request Feb 21, 2023
This is re-application of commit b8196b1 with the same subject alas
this time borsh is updated to 0.10.2.  Previous attempt to update the
dependency was reverted becauses of potential DOS which was addressed
in borsh 0.10.2 (see <near/borsh-rs#129>).

Like before, the update is mostly just a matter of replacing deserialize
function in BorshDeserialize implementation by deserialize_reader.  In
a few of existing custom implementations for (de)serialization could be
removed alltogether.
near-bulldozer bot pushed a commit to near/nearcore that referenced this pull request Feb 21, 2023
This is re-application of commit b8196b1 with the same subject alas
this time borsh is updated to 0.10.2.  Previous attempt to update the
dependency was reverted becauses of potential DOS which was addressed
in borsh 0.10.2 (see <near/borsh-rs#129>).

Like before, the update is mostly a matter of replacing deserialize
function in BorshDeserialize implementations by deserialize_reader.
In a few of existing custom implementations for (de)serialization
could be removed altogether.
This was referenced May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants