chore(deps): update dependency nerdbank.messagepack to 1.2.4 [security]#137
Open
renovate[bot] wants to merge 1 commit into
Open
chore(deps): update dependency nerdbank.messagepack to 1.2.4 [security]#137renovate[bot] wants to merge 1 commit into
renovate[bot] wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
1.1.62→1.2.4Nerdbank.MessagePack has a memory amplification DoS in collection deserialization
GHSA-qjvr-435c-5fjh
More information
Details
Nerdbank.MessagePack deserializers for many collection-shaped types trusted the element count declared in MessagePack array and map headers when allocating destination storage. A crafted payload could therefore force large arrays, pooled buffers, dictionaries, or collection instances to be allocated before the deserializer had consumed the corresponding elements.
The same allocation pattern existed across strongly typed arrays, primitive arrays, mutable and immutable dictionaries, mutable enumerables, span-backed enumerable construction,
JsonNode,MessagePackValue, and the object/dynamic primitive converters.Because MessagePack array and map headers carry an attacker-controlled element count, any converter that immediately allocates
countelements or constructs a collection with capacitycountcan turn a payload that is merely large into a much larger managed heap allocation. The reader's residency checks reduce the most extreme header-only attack shape, but they do not remove the memory amplification: minimal MessagePack elements can be one or two bytes on the wire while the managed representation may require object references, dictionary buckets, entries, array headers, or over-allocated collection internals.Vulnerability Pattern
Affected converters followed one or both of these patterns:
or, for streaming and span-backed construction:
In all affected cases, the allocation size was derived from the untrusted header count before the converter had read the elements. This made deserialization vulnerable to memory amplification and process availability attacks.
Affected Scope
The vulnerable logic was present in multiple converter families:
ArrayConverter<TElement>new TElement[count]for typed arrays and rented large buffers in async paths.ArraysOfPrimitivesConvertersTElement[count]for primitive array and span-constructor paths.MutableEnumerableConverter<TEnumerable, TElement>SpanEnumerableConverter<TEnumerable, TElement>MutableDictionaryConverter<TDictionary, TKey, TValue>ImmutableDictionaryConverter<TDictionary, TKey, TValue>KeyValuePair<TKey, TValue>[count]before reading entries.PrimitivesAsObjectConverterandPrimitivesAsDynamicConverterJsonNodeConverterJsonNode?[]from the declared array length.MessagePackValueConverterThis means the issue affects normal typed deserialization as well as object/dynamic APIs.
Any endpoint or protocol surface that accepts untrusted MessagePack and deserializes collection-shaped contracts can be affected.
Attack Mechanics
MessagePack encodes array and map lengths up front. For
array32andmap32, the declared count can be very large. The reader checks that enough bytes remain to plausibly contain the declared number of elements, so an attacker must provide real payload bytes. However, the managed allocation can still be much larger than the payload.Examples:
array32ofnilvalues intoobject?[]map32of small keys andnilvalues intoDictionary<object, object?>array32into typed reference arraysnilelement when element type allows nullarray32into immutable dictionary staging buffersKeyValuePair<TKey, TValue>[]staging allocation before construction.map32into typed dictionariesAt larger counts, the attack can trigger
OutOfMemoryException, force full blocking garbage collections, or degrade service through repeated moderate allocations. The impact is availability loss rather than confidentiality or integrity compromise.Impact
An attacker who can deliver crafted MessagePack data to an endpoint that deserializes collections can:
OutOfMemoryExceptionfrom a single large payload.Concrete affected configurations include:
JsonNode,MessagePackValue,object, ordynamicmembers.Deserialize<T>()whereTcontains collection-shaped members.DeserializePrimitives()orDeserializeDynamicPrimitives()on untrusted input.WithObjectConverter()orWithDynamicObjectConverter()for framework integration or ad hoc object graphs.Severity Rationale
Attack complexity is low. Once an application accepts untrusted MessagePack for an affected collection type, exploitation only requires a crafted array or map payload with a large declared count and minimal encoded elements.
Privileges required depend on deployment. Public endpoints are exploitable without authentication. Internal or authenticated message-processing systems reduce exposure but remain vulnerable to any caller who can submit MessagePack data.
User interaction is not required. The attack is triggered during server-side or service-side deserialization.
Availability impact is low. The practical outcome is memory pressure which can slow down a process or machine, or cause a network request to fail.
Proof of Concept
The following sample demonstrates the original object/dynamic shape and a typed array shape. Both rely on the same underlying bug: allocation is derived from the MessagePack header count before the elements are consumed.
Confirmed output against the vulnerable implementation included object-array amplification around 8x and dictionary amplification above 20x for moderate payload sizes. Typed collection amplification varies by element type and target collection implementation, but the same attacker-controlled preallocation primitive is present.
Remediation
The deserializer honors input data's prefixed collection sizes up to a reasonable limit, after which the collections grow when the data is actually encountered, such that memory amplification is limited to only small amounts over the size of the data being deserialized.
Prior Art
CVE-2026-21452 / GHSA-cw39-r4h6-8j3x: MessagePack for Java. An EXT32 object with an attacker-controlled payload length caused
ExtensionValue.getData()to allocate a byte array of that size with no upper bound. This is the same vulnerability class: header-declared size leading to attacker-controlled heap allocation. It was fixed inmsgpack-java0.9.11 by avoiding unbounded allocation.CVE-2024-48924 / GHSA-4qm4-8hg2-g2xm: MessagePack-CSharp. Untrusted data could trigger denial of service during deserialization through a different mechanism. It demonstrates the same ecosystem-level risk: MessagePack deserializers are frequently reachable on network and message-processing boundaries, where availability defects are exploitable.
Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:LReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Nerdbank.MessagePack has Inefficient CPU Computation
GHSA-92vj-hp7m-gwcj
More information
Details
Impact
Applications that call
OptionalConverters.WithExpandoObjectConverterand deserialize untrusted data are open to a vulnerability by which an attacker can exploit aO(n²)algorithm to burn an inordinate amount of CPU effort by adding a great many properties to anExpandoObject, whoseAddmethod is implemented as anO(n)algorithm.Patches
Update to a patched version.
If a project's
ExpandoObjectdata requires more than 128 properties, the default limit should be changed:Workarounds
Avoid the non-default
WithExpandoObjectConverterextension method when deserializing untrusted data.If deserializing untrusted data into an
ExpandoObjectis required, developers should write a custom converter for their project that limits the number of properties allowed before initializing the object.Severity
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:LReferences
This data is provided by the GitHub Advisory Database (CC-BY 4.0).
Release Notes
AArnott/Nerdbank.MessagePack (Nerdbank.MessagePack)
v1.2.4Security fix
SecuritySettingsclass by @AArnott in #960 to fix GHSA-92vj-hp7m-gwcjFull Changelog: AArnott/Nerdbank.MessagePack@v1.1.78...v1.2.4
v1.1.78Security fix
Full Changelog: AArnott/Nerdbank.MessagePack@v1.1.68...v1.1.78
Configuration
📅 Schedule: (UTC)
* 0-3 * * 1)🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.