CVE-2026-48516: MessagePack-CSharp: InterfaceLookupFormatter bypasses collision-resistant comparer settings
Summary
InterfaceLookupFormatter<TKey,TElement> constructs an internal Dictionary<TKey, IGrouping<TKey,TElement>> with the default equality comparer instead of the security-aware comparer supplied by options.Security.GetEqualityComparer<TKey>().
Other hash-based collection formatters use the security-aware comparer when MessagePackSecurity.UntrustedData is configured. This formatter omission allows hash-collision CPU denial of service against ILookup<TKey,TElement> even when the application has opted into the untrusted-data security posture.
Impact
Applications are affected when they deserialize untrusted payloads into schemas containing ILookup<TKey,TElement> with a key type for which attacker-controlled hash collisions are feasible.
Under the default comparer, many colliding keys can degrade dictionary insertion from amortized constant time to quadratic behavior. A payload of colliding keys can consume CPU for a disproportionate amount of time. This bypasses the mitigation that developers intentionally enabled by using MessagePackSecurity.UntrustedData.
Affected components
- Package: MessagePack - API: InterfaceLookupFormatter<TKey,TElement>.Create - Data type: ILookup<TKey,TElement> - Finding ID: MESSAGEPACKCSHARP-041
Patches
Fixes are prepared and will be released in coordinated patch versions.
Upgrade guidance:
1. Upgrade MessagePack to the patched version for your release line. 2. Upgrade companion MessagePack packages in the same dependency graph to the coordinated patched versions.
The fix should create the internal dictionary with options.Security.GetEqualityComparer<TKey>(), matching the sibling dictionary and lookup formatter behavior.
Workarounds
Patching is recommended.
Until a patched version is available, avoid exposing ILookup<TKey,TElement> in DTOs that deserialize untrusted data. Use collection shapes that are already protected by the security-aware comparer path, or validate and cap collection sizes at the transport boundary.
Resources
- MESSAGEPACKCSHARP-041: InterfaceLookupFormatter missing security comparer - CWE-407: Inefficient Algorithmic Complexity
Other sources
MessagePack for C# is a MessagePack serializer for C#. Prior to 2.5.301 and 3.1.7, InterfaceLookupFormatter<TKey,TElement> constructs an internal Dictionary<TKey, IGrouping<TKey,TElement>> with the default equality comparer instead of the security-aware comparer supplied by options.Security.GetEqualityComparer<TKey>(). This formatter omission allows hash-collision CPU denial of service against ILookup<TKey,TElement> even when the application has opted into the untrusted-data security posture This vulnerability is fixed in 2.5.301 and 3.1.7.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
nuget/MessagePackto a version that resolves this vulnerability.Fixed in 3.1.7 - Upgrade
Upgrade
nuget/MessagePackto a version that resolves this vulnerability.Fixed in 2.5.301 - Upgrade
Upgrade
MessagePackto a version that resolves this vulnerability.Fixed in 2.5.301 - Upgrade
Upgrade
MessagePackto a version that resolves this vulnerability.Fixed in 3.1.7 - Configuration
In InterfaceLookupFormatter<TKey,TElement>, construct the internal Dictionary<TKey, IGrouping<TKey,TElement>> using options.Security.GetEqualityComparer<TKey>() (instead of the default equality comparer) so it matches the security-aware comparer behavior for MessagePackSecurity.UntrustedData.
MessagePack InterfaceLookupFormatter<TKey,TElement> internal Dictionary<TKey, IGrouping<TKey,TElement>> equality comparer = options.Security.GetEqualityComparer<TKey>() - Compensating control
Until patched, avoid exposing ILookup<TKey,TElement> in DTOs that deserialize untrusted data.
Event History
Frequently Asked Questions
What is the severity of CVE-2026-48516?
CVE-2026-48516 is rated with a risk score of 28, indicating a medium-level security vulnerability.
How do I fix CVE-2026-48516?
To resolve CVE-2026-48516, upgrade to MessagePack for C# version 2.5.301 or 3.1.7 or later.
What systems are affected by CVE-2026-48516?
CVE-2026-48516 affects MessagePack for C# versions prior to 2.5.301 and 3.1.7.
What is the nature of the issue in CVE-2026-48516?
CVE-2026-48516 allows the InterfaceLookupFormatter to bypass user-defined equality comparer settings, using a default comparer instead.
Is CVE-2026-48516 a remote exploit?
CVE-2026-48516 does not indicate a remote exploitation vector, but it may lead to unexpected behavior in applications using the affected versions.