/

CVE-2026-48517

Severity:

HIGH RISK

(7.5)

Unsafe Typeless Deserialization (CWE-502) in MessagePack

CVE-2026-48517

Analyzed

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-470, CWE-502

Impact:

Remote Code Execution / Privilege Escalation

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

MessagePack for C# contains an unsafe typeless deserialization flaw where dangerous types can bypass restriction checks when wrapped in arrays or generic containers.

If an attacker can supply crafted MessagePack payloads to typeless deserialization APIs, this can result in the instantiation of disallowed types and potential remote code execution or privilege escalation.

Affected context

This vulnerability affects applications using MessagePack for C# typeless deserialization (e.g., MessagePackSerializer.Deserialize<object> or similar APIs) with the default MessagePackSerializerOptions.ThrowIfDeserializingTypeIsDisallowed(Type) safety checks.

It becomes relevant when the application relies on type-allow/deny lists for protection but accepts untrusted or semi-trusted MessagePack input that can be controlled or influenced by an attacker.

The issue manifests specifically when blocked types are nested inside arrays or generic types, as only the outer container type name is inspected by the default implementation.

Exploit preconditions

  • Attack surface: Any endpoint, message handler, or IPC boundary that performs typeless MessagePack deserialization on attacker-controlled data.
  • Required access: Ability to send or inject crafted MessagePack payloads into the deserialization process (e.g., over HTTP, WebSocket, RPC, or queue-based messaging).
  • Trigger point: Invocation of typeless deserialization methods that rely on ThrowIfDeserializingTypeIsDisallowed(Type) for enforcing type restrictions.
  • Why exploitation is possible: The type safety check inspects only the outer container type (array or generic type) and does not recursively examine element types or generic arguments, allowing forbidden types to be nested and still have formatters generated and invoked.

Why this happens

The underlying bug is an incomplete type validation strategy in the typeless deserialization pipeline.

MessagePack-CSharp relies on ThrowIfDeserializingTypeIsDisallowed(Type) to block dangerous or sensitive types at deserialization time (mapping to CWE-470: Use of Externally-Controlled Input to Select Classes or Code and CWE-502: Deserialization of Untrusted Data).

However, the default implementation checks only the top-level type name and does not perform a recursive inspection of element types for arrays or generic type arguments.

As a result, an attacker can wrap a blocked type inside a permitted container type, bypass the outer check, and cause formatter machinery to materialize and operate on the inner disallowed type, undermining the intended safety boundary around typeless deserialization.

Potential impact

  • Attackers may be able to instantiate disallowed types that perform sensitive operations during construction, deserialization, or method invocation.
  • Exploitation could lead to remote code execution within the application process, depending on available dangerous types and environment configuration.
  • Applications can experience privilege escalation if deserialized types access higher-privileged resources or system capabilities.
  • Security controls that rely on allow/deny lists for deserialization safety may be rendered ineffective, increasing the risk of data exfiltration or configuration tampering.
  • Abuse of deserialized types may enable service disruption, denial of service, or manipulation of business logic.

General mitigation guidance

Mitigation generally focuses on reducing trust in typeless deserialization and strengthening type validation boundaries.

Recommended defensive patterns include:

  • Avoid typeless or polymorphic deserialization for untrusted data; prefer strongly-typed contracts with explicitly defined DTOs and schema-based validation.
  • Implement recursive type inspection for arrays, collections, and generic types when enforcing type allow/deny lists, ensuring inner element and argument types are validated.
  • Maintain strict, minimal allow lists for deserializable types and avoid including classes with side effects, IO, reflection, or process-level capabilities.
  • Isolate deserialization logic into low-privilege components or sandboxes to limit the blast radius if dangerous types are instantiated.
  • Apply input validation and protocol-level checks before deserialization to reject malformed or unexpected payloads early.
  • Use secure-by-default serializer options that disable typeless deserialization for untrusted channels and require explicit opt-in for advanced scenarios.

How teams detect issues like this

Effective detection typically involves both code-centric and deployment-centric practices:

  • Use static analysis or custom Roslyn analyzers to flag typeless MessagePack deserialization calls (e.g., Deserialize<object>, Deserialize<dynamic>) in code paths that accept untrusted input.
  • During code review, look for reliance on ThrowIfDeserializingTypeIsDisallowed(Type) or similar mechanisms without recursive validation of arrays, collections, and generic arguments.
  • Define secure coding policies that prohibit or restrict typeless deserialization in high-risk components such as API controllers, message brokers, or external integration layers.
  • Integrate automated security scanning tools into CI pipelines to detect patterns of unsafe deserialization across the codebase.
  • Monitor runtime logs or telemetry for unexpected type activation or formatter generation in deserialization pipelines, which may indicate abuse of nested container types.

Sources

SourceLink
github.comgithub.com/MessagePack-CSharp/MessagePack-CSharp/security/advisories/GHSA-qhmf-xw27-6rqr

Frequently asked

questions

Exploitability depends on whether your application uses typeless MessagePack deserialization on data that an attacker can influence. Systems that deserialize arbitrary objects from external clients or untrusted services are at higher risk, whereas internal-only, strongly-typed deserialization scenarios are less exposed.

An attacker typically needs the ability to send crafted MessagePack payloads to a vulnerable endpoint or message handler. No local filesystem or OS-level access is required; control over the serialized input stream is the primary prerequisite.

The safest pattern is to eliminate typeless deserialization for untrusted data and migrate to strongly-typed, schema-driven DTOs. Complement this with strict allow lists for deserializable types and recursive validation of container element types whenever type filtering is used.

Preventive strategies include establishing serialization guidelines that forbid polymorphic/typeless deserialization on untrusted data, enforcing these rules via static analysis and code review, adopting serializers with secure defaults, and isolating deserialization logic in low-privilege components that minimize the impact of any type misuse.

Find out what's already
exploitable in your codebase.