.NET Deserialization

Insecure use of .NET formatters (BinaryFormatter, LosFormatter, ObjectStateFormatter, NetDataContractSerializer, SoapFormatter) and type-binding JSON/XML serializers (Json.NET with TypeNameHandling, JavaScriptSerializer, FastJSON) on attacker data, where the payload names the type to instantiate and setter/callback logic runs during reconstruction.

How it works

  • BinaryFormatter is unsafe by design. Microsoft’s own guidance states it “is insecure and can’t be made secure,” and calling Deserialize on a payload is “the equivalent of interpreting that payload as a standalone executable.” A SerializationBinder is insufficient. From .NET 9 the in-box implementation throws on use.
  • Type discriminators are the root cause for JSON/XML. Json.NET with TypeNameHandling other than None, JavaScriptSerializer with a type resolver, and similar settings let the payload’s $type/__type field pick a .NET class to construct; setters and type converters then run. The Black Hat “Friday the 13th JSON Attacks” research generalised this: format (binary/XML/JSON) is irrelevant as long as the library invokes methods on user-named types and a gadget space exists.
  • Magic bytes. BinaryFormatter/LosFormatter base64 commonly begins AAEAAAD/////; ASP.NET ViewState begins /wE. ysoserial.net and Mandiant’s heyserial are the reference payload/detection tooling.

ASP.NET ViewState

_VIEWSTATE is serialized state round-tripped through a hidden field (serialized by LosFormatter, deserialized by ObjectStateFormatter, which uses BinaryFormatter internally plus type converters). Its integrity rests on the server’s machineKey (validation/decryption keys). Exploitability hinges on key secrecy and MAC configuration:

  • A leaked or sample machineKey (in web.config, deployment guides, or disk via file-read) turns ViewState into an attacker-signable deserialization sink.
  • Pre-.NET-4.5, ViewStateEncryptionMode=Always only checked for the presence of __VIEWSTATEENCRYPTED; .NET ≥4.5 binds target-framework behaviour. Treat a leaked machineKey as equivalent to a deserialization RCE. See Insecure Deserialization.

Notable cases

CVE / IDTargetNote
CVE-2025-53690SitecoreViewState RCE via a sample machineKey published in 2017 deployment guides; in-the-wild, WEEPSTEEL recon (Mandiant)
CVE-2025-53770 “ToolShell”SharePoint on-premUnauth; webshell parsing ViewState payloads; mass-exploited, chained with Ivanti EPMM bugs
CVE-2025-59287WSUSUnauth SoapUtilities.DeserializeObject in ReportingEvent.Validate, port 8530/8531; in-the-wild, w3wp.exe→whoami.exe
CVE-2026-28326SolarWinds ARMHardcoded static client-auth secret → .NET deserialization over gRPC on TCP 55555; RCE as SYSTEM
CVE-2025-34153Hyland OnBaseBinaryFormatter over .NET Timer Service TCP 6031
CVE-2025-5086DELMIA AprisoNetDataContractSerializer in a WCF service; in-the-wild (CISA KEV)
CVE-2026-131914Idunno.AntiCsrf 0.9.1 (ASP.NET WebForms IHttpModule)CVSS 9.3. The double-submit anti-CSRF module deserializes the form token with an unkeyed ObjectStateFormatter (no MAC or signature) on every POST to a Page: any non-empty CSRF cookie plus a base64 gadget chain in the form field → RCE in w3wp.exe, no auth or valid token. Exploited in the wild (Mandiant); project dead since 2008, no patch. Replace with System.Web.Helpers.AntiForgery, ViewStateUserKey + MAC’d ViewState, or ASP.NET Core IAntiforgery; hunt AntiCsrfModule in Web.config/bin/, and after compromise rotate <machineKey> and other Web.config secrets (THN)
CVE-2025-55182 “React2Shell”React 19 / Next.js RSCUnsafe deserialization in the RSC “Flight” protocol; CVSS 10.0, default configs

Also: Telerik UI for ASP.NET AJAX padding-oracle→deserialization (and Telerik Reporting / UI for WPF), RBH Integra32 and Quest Foglight unauth .NET Remoting, Visual Studio PDB handling (CVE-2026-114151), SharePoint DataSet/DataTable (CVE-2020-1147), and the .NET/C# type-binding JSON cases from Black Hat.

Prevention

  • Stop using BinaryFormatter, LosFormatter, ObjectStateFormatter, NetDataContractSerializer, SoapFormatter on untrusted data; prefer XmlSerializer/DataContractSerializer/System.Text.Json with concrete expected types.
  • Json.NET: keep TypeNameHandling = None; if type info is required, use a strict SerializationBinder allowlist.
  • ViewState: keep machineKey secret and unique per deployment (never a sample key), enable MAC, and rotate keys after any suspected disclosure. Restrict management ports (gRPC 55555, Timer 6031, Remoting 2001) to their own components.

Sources