Loading...
Skip to main content

CVE-2020-5234 — Vulnerability in MessagePack — CVE Details

MEDIUM

Untrusted data can lead to DoS attack due to hash collisions and stack overflow in MessagePack

Published January 31, 2020Updated September 10, 2026Source: osv

Summary

### Impact When this library is used to deserialize messagepack data from an untrusted source, there is a risk of a denial of service attack by either of two vectors: 1. hash collisions - leading to large CPU consumption disproportionate to the size of the data being deserialized. 1. stack overflow - leading to the deserializing process crashing. ### Patches The following steps are required to mitigate this risk. 1. Upgrade to a version of the library where a fix is available 1. Add code to your application to put MessagePack into the defensive `UntrustedData` mode. 1. Identify all MessagePack extensions that implement `IMessagePackFormatter<T>` implementations that do not ship with the MessagePack library to include the security mitigations. This includes those acquired from 3rd party packages and classes included directly into your project. Any AOT formatters generated with the MPC tool must be regenerated with the patched version of mpc. 1. Review your messagepack-serializable data structures for hash-based collections that use custom or unusual types for the hashed key. See below for details on handling such situations. Review the `MessagePackSecurity` class to tweak any settings as necessary to strike the right balance between performance, functionality, and security. Specialized `IEqualityComparer<T>` implementations provide the hash collision resistance. Each type of hashed key may require a specialized implementation of its own. The patched MessagePack library includes many such implementations for primitive types commonly used as keys in hash-based collections. If your data structures use custom types as keys in these hash-based collections, putting MessagePack in `UntrustedData` mode may lead the deserializer to throw an exception because no safe `IEqualityComparer<T>` is available for your custom `T` type. You can provide your own safe implementation by deriving from the `MessagePackSecurity` class and overriding the `GetHashCollisionResistantEqualityComparer<T>()` method to return your own custom implementation when `T` matches your type, and fallback to `return base.GetHashCollisionResistantEqualityComparer<T>();` for types you do not have custom implementations for. Unrelated to this advisory, but as general security guidance, you should also avoid the Typeless serializer/formatters/resolvers for untrusted data as that opens the door for the untrusted data to potentially deserialize unanticipated types that can compromise security. #### MessagePack 1.x users 1. Upgrade to any 1.9.x version. 1. When deserializing untrusted data, put MessagePack into a more secure mode with: ```cs MessagePackSecurity.Active = MessagePackSecurity.UntrustedData; ``` In MessagePack v1.x this is a static property and thus the security level is shared by the entire process or AppDomain. Use MessagePack v2.1 or later for better control over the security level for your particular use. 1. Any code produced by mpc should be regenerated with the mpc tool with the matching (patched) version. Such generated code usually is written to a file called `Generated.cs`. A patched `Generated.cs` file will typically reference the `MessagePackSecurity` class. Review any custom-written `IMessagePackFormatter<T>` implementations in your project or that you might use from 3rd party packages to ensure they also utilize the `MessagePackSecurity` class as required. In particular, a formatter that deserializes an object (as opposed to a primitive value) should wrap the deserialization in a `using (MessagePackSecurity.DepthStep())` block. For example: ```cs public MyObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } else { using (MessagePackSecurity.DepthStep()) // STACK OVERFLOW MITIGATION { MyObject o = new MyObject(); // deserialize members of the object here. return o; } } } ``` If your custom formatter creates hash-based collections (e.g. `Dictionary<K, V>` or `HashSet<T>`) where the hashed key comes from the messagepack data, always instantiate your collection using `MessagePackSecurity.Active.GetEqualityComparer<T>()` as the equality comparer: ```cs var collection = new HashSet<T>(MessagePackSecurity.Active.GetEqualityComparer<T>()); ``` This ensures that when reading untrusted data, you will be using a collision-resistent hash algorithm. Learn more about [best security practices when reading untrusted data with MessagePack 1.x](https://github.com/neuecc/MessagePack-CSharp/tree/v1.x#security). #### MessagePack 2.x users 1. Upgrade to any 2.1.x or later version. 1. When deserializing untrusted data, put MessagePack into a more secure mode by configuring your `MessagePackSerializerOptions.Security` property: ```cs var options = MessagePackSerializerOptions.Standard .WithSecurity(MessagePackSecurity.UntrustedData); // Pass the options explicitly for the greatest control. T object = MessagePackSerializer.Deserialize<T>(data, options); // Or set the security level as the default. MessagePackSerializer.DefaultOptions = options; ``` 1. Any code produced by mpc should be regenerated with the mpc tool with the matching (patched) version. Such generated code usually is written to a file called `Generated.cs`. A patched `Generated.cs` file will typically reference the `Security` member on the `MessagePackSerializerOptions` parameter. Review any custom-written `IMessagePackFormatter<T>` implementations in your project or that you might use from 3rd party packages to ensure they also utilize the `MessagePackSecurity` class as required. In particular, a formatter that deserializes an object (as opposed to a primitive value) should call `options.Security.DepthStep(ref reader);` before deserializing the object's members, and be sure to revert the depth step with `reader.Depth--;` before exiting the method. For example: ```cs public MyObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { if (reader.TryReadNil()) { return default; } else { options.Security.DepthStep(ref reader); // STACK OVERFLOW MITIGATION, line 1 try { MyObject o = new MyObject(); // deserialize members of the object here. return o; } finally { reader.Depth--; // STACK OVERFLOW MITIGATION, line 2 } } } ``` If your custom formatter creates hash-based collections (e.g. `Dictionary<K, V>` or `HashSet<T>`) where the hashed key comes from the messagepack data, always instantiate your collection using `options.Security.GetEqualityComparer<TKey>()` as the equality comparer: ```cs var collection = new HashSet<T>(options.Security.GetEqualityComparer<T>()); ``` This ensures that when reading untrusted data, you will be using a collision-resistent hash algorithm. Learn more about [best security practices when reading untrusted data with MessagePack 2.x](https://github.com/neuecc/MessagePack-CSharp#security). ### Workarounds The security vulnerabilities are in the formatters. Avoiding the built-in formatters entirely in favor of reading messagepack primitive data directly or relying on carefully written custom formatters can provide a workaround. MessagePack v1.x users may utilize the `MessagePackBinary` static class directly to read the data they expect. MessagePack v2.x users may utilize the `MessagePackReader` struct directly to read the data they expect. ### References Learn more about best security practices when reading untrusted data with [MessagePack 1.x](https://github.com/neuecc/MessagePack-CSharp/tree/v1.x#security) or [MessagePack 2.x](https://github.com/neuecc/MessagePack-CSharp#security). ### For more information If you have any questions or comments about this advisory: * Open an issue in [MessagePack-CSharp](https://github.com/neuecc/MessagePack-CSharp/issues/new/choose) * [Email us](mailto:andrewarnott@gmail.com)

Advisory Timeline

  • First published January 31, 2020 (2446 days ago).
  • Last revised September 10, 2026 — 2413 days after initial publication.

Remediation

Upgrade to the fixed version using your package manager.

NuGet
Update MessagePack to 2.1.90 or later
dotnet add package MessagePack --version 2.1.90
NuGet
Update MessagePack.ImmutableCollection to 1.9.11 or later
dotnet add package MessagePack.ImmutableCollection --version 1.9.11
NuGet
Update MessagePack to 1.9.11 or later
dotnet add package MessagePack --version 1.9.11
NuGet
Update MessagePack.ImmutableCollection to 2.1.90 or later
dotnet add package MessagePack.ImmutableCollection --version 2.1.90
NuGet
Update MessagePack.UnityShims to 1.9.11 or later
dotnet add package MessagePack.UnityShims --version 1.9.11
NuGet
Update MessagePack.ReactiveProperty to 2.1.90 or later
dotnet add package MessagePack.ReactiveProperty --version 2.1.90
NuGet
Update MessagePack.Unity to 1.9.11 or later
dotnet add package MessagePack.Unity --version 1.9.11
NuGet
Update MessagePack.Unity to 2.1.90 or later
dotnet add package MessagePack.Unity --version 2.1.90
NuGet
Update MessagePack.UnityShims to 2.1.90 or later
dotnet add package MessagePack.UnityShims --version 2.1.90
NuGet
Update MessagePack.ReactiveProperty to 1.9.11 or later
dotnet add package MessagePack.ReactiveProperty --version 1.9.11

After upgrading, run your dependency scanner again to confirm the vulnerability is resolved.

Affected Packages (10)

Affects 1 ecosystem: nuget (5).

PackageEcosystemAffectedFixed In
MessagePack
nuget
2.0.107-alpha, 2.0.108-alpha, 2.0.110-alpha, 2.0.110-alpha-g1e44a9106f (+11 more)2.1.90
MessagePack.ImmutableCollection
nuget
0.2.0-beta, 0.3.0-beta, 0.4.0, 0.4.1 (+58 more)1.9.11
MessagePack
nuget
0.1.0-beta, 0.2.0-beta, 0.2.1-beta, 0.2.2-beta (+66 more)1.9.11
MessagePack.ImmutableCollection
nuget
2.0.107-alpha, 2.0.108-alpha, 2.0.110-alpha, 2.0.110-alpha-g1e44a9106f (+11 more)2.1.90
MessagePack.UnityShims
nuget
0.6.0, 0.6.1, 0.7.0, 0.7.2 (+53 more)1.9.11
MessagePack.ReactiveProperty
nuget
2.0.107-alpha, 2.0.108-alpha, 2.0.110-alpha, 2.0.110-alpha-g1e44a9106f (+11 more)2.1.90
MessagePack.Unity
nuget
0.2.0-beta, 0.3.0-beta, 0.4.0, 0.4.1 (+1 more)1.9.11
MessagePack.Unity
nuget
All versions2.1.90
MessagePack.UnityShims
nuget
2.0.107-alpha, 2.0.108-alpha, 2.0.110-alpha, 2.0.110-alpha-g1e44a9106f (+11 more)2.1.90
MessagePack.ReactiveProperty
nuget
0.1.0-beta, 0.2.0-beta, 0.3.0-beta, 0.4.0 (+60 more)1.9.11

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 4.8 score means for each attack dimension.

Attack Vector
Network
Attack Complexity
High
Privileges Required
Low
User Interaction
Required
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
High

CVSS:3.1/AV:N/AC:H/PR:L/UI:R/S:U/C:N/I:N/A:H

Frequently Asked Questions

What is CVE-2020-5234?
Untrusted data can lead to DoS attack due to hash collisions and stack overflow in MessagePack This vulnerability has been assigned a severity rating of MEDIUM (CVSS score: 4.8/10).
How do I check if my project is affected by CVE-2020-5234?
CVE-2020-5234 affects MessagePack, MessagePack.ImmutableCollection and MessagePack.UnityShims (and 2 more). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2020-5234 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
4.8

Exploitation requires specific conditions or has limited impact. Remediate within weeks.

Also Known As

GHSA-7q36-4xx7-xcxf

Related CVEs

  • CVE-2026-48502
    HIGH

    MessagePack-CSharp: Denial of service vulnerabilities can swamp the CPU or crash the process with stack and heap overflows

  • CVE-2026-48109
    HIGH

    MessagePack's LZ4 decompression may fail with AccessViolationException after dereferencing memory from bad input

  • CVE-2026-48506
    HIGH

    MessagePack-CSharp: MessagePackReader.Skip can recurse without enforcing maximum object graph depth

  • CVE-2026-48509
    MEDIUM

    MessagePack-CSharp: ASP.NET Core MessagePackInputFormatter defaults to TrustedData for HTTP request bodies

  • CVE-2026-48511
    MEDIUM

    MessagePack-CSharp: ExpandoObject formatter can perform quadratic insertion work on untrusted maps

  • CVE-2026-106111
    MEDIUM

    ImageSharp: EXR ZIP decoder can expose stale allocator data after a short inflate

  • CVE-2026-65829
    MEDIUM

    MPXJ: Potential Path Traversal Vulnerability in Primavera P3 PRX and SureTrak STX readers

  • CVE-2026-48510
    MEDIUM

    MessagePack-CSharp: LZ4 decompression allocates from unbounded declared output lengths

Check if you're affected

Scan your dependencies to see if this vulnerability affects your projects.

Scan Your Dependencies