Courses

.NET Deserialization
OSWE · Chapter 7

.NET Deserialization

.NET deserialization vulnerabilities occur when an application deserializes attacker-controlled data using an unsafe binder that can instantiate arbitrary types — some of which have side effects (like running a process) purely as part of being constructed, leading directly to remote code execution.

Key concepts

  • `BinaryFormatter` is considered unsafe by Microsoft itself and cannot be secured for untrusted input — it should not be used at all for that purpose.
  • Known "gadget chains" (e.g. via `ObjectDataProvider`, `WorkflowDesigner`) turn an apparently harmless deserialization call into arbitrary code execution.
  • Detection clue: base64 data starting with `AAEAAAD/////` is the signature of a .NET binary-serialized payload worth investigating.
  • Safer alternatives: use `DataContractSerializer`/`System.Text.Json` with strict type allow-lists, and never let the incoming data stream dictate which type gets instantiated.

Try it yourself

Research the `ysoserial.net` tool's README (without running it against anything but your own lab) and identify which gadget chain targets `ObjectDataProvider`, and what real-world component (WPF) that gadget depends on.

@ Daniel Burlacu