Ecosyste.ms: Advisories
An open API service providing security vulnerability metadata for many open source software ecosystems.
Security Advisories: GSA_kwCzR0hTQS00cW00LThoZzItZzJ4bc4ABAZj
MessagePack allows untrusted data to lead to DoS attack due to hash collisions and stack overflow
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 an attacker that sends data contrived to produce hash collisions, leading to large CPU consumption disproportionate to the size of the data being deserialized.
This is similar to a prior advisory, which provided an inadequate fix for the hash collision part of the vulnerability.
Patches
The following steps are required to mitigate this risk.
- Upgrade to a version of the library where a fix is available. If upgrading from v1, check out our migration guide.
- Review the steps in this previous advisory to ensure you have your application configured for untrusted data.
Workarounds
If upgrading MessagePack to a patched version is not an option for you, you may apply a manual workaround as follows:
- Declare a class that derives from
MessagePackSecurity
. - Override the
GetHashCollisionResistantEqualityComparer<T>
method to provide a collision-resistant hash function of your own and avoid callingbase.GetHashCollisionResistantEqualityComparer<T>()
. - Configure a
MessagePackSerializerOptions
with an instance of your derived type by callingWithSecurity
on an existing options object. - Use your custom options object for all deserialization operations. This may be by setting the
MessagePackSerializer.DefaultOptions
static property, if you call methods that rely on this default property, and/or by passing in the options object explicitly to anyDeserialize
method.
References
- Learn more about best security practices when reading untrusted data with MessagePack 1.x or MessagePack 2.x.
- The .NET team's discussion on hash collision vulnerabilities of their
HashCode
struct (or in the pull request that merges this into the dotnet org).
For more information
If you have any questions or comments about this advisory:
Permalink: https://github.com/advisories/GHSA-4qm4-8hg2-g2xmJSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS00cW00LThoZzItZzJ4bc4ABAZj
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Moderate
Classification: General
Published: 20 days ago
Updated: 19 days ago
Identifiers: GHSA-4qm4-8hg2-g2xm, CVE-2024-48924
References:
- https://github.com/MessagePack-CSharp/MessagePack-CSharp/security/advisories/GHSA-4qm4-8hg2-g2xm
- https://github.com/advisories/GHSA-4qm4-8hg2-g2xm
Blast Radius: 1.0
Affected Packages
nuget:MessagePack
Dependent packages: 519Dependent repositories: 0
Downloads: 150,783,093 total
Affected Version Ranges: >= 2.6.95-alpha, < 3.0.214-rc.1, < 2.5.187
Fixed in: 3.0.214-rc.1, 2.5.187
All affected versions: 0.4.0, 0.4.1, 0.4.2, 0.5.0, 0.6.0, 0.6.1, 0.7.0, 0.7.2, 0.8.0, 0.8.1, 0.8.2, 0.8.3, 0.8.4, 0.8.5, 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.1.0, 1.1.1, 1.1.2, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.4.0, 1.4.1, 1.4.2, 1.4.3, 1.4.4, 1.5.0, 1.5.1, 1.6.0, 1.6.1, 1.6.2, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.8.74, 1.8.80, 1.9.3, 1.9.11, 2.0.323, 2.0.335, 2.1.80, 2.1.90, 2.1.115, 2.1.143, 2.1.152, 2.1.165, 2.1.194, 2.2.60, 2.2.85, 2.2.113, 2.3.75, 2.3.85, 2.3.112, 2.4.35, 2.4.59, 2.5.94, 2.5.103, 2.5.108, 2.5.124, 2.5.129, 2.5.140, 2.5.168, 2.5.171, 2.5.172, 2.6.95-alpha
All unaffected versions: 2.5.187