Skip to content
RCE Write-up Advanced

[Blog] Bypassing .NET Serialization Binders

The post explains that .NET serialization binders used to block dangerous types during deserialization can be bypassed when they parse type and assembly names differently from the runtime, or return null on failure so the runtime falls back to its own binder. Two real binders, in DevExpress and Microsoft Exchange, were bypassed this way, allowing remote code execution.

code-white.com

Published on code-white.com

Serialization binders are often used to validate types specified in the serialized data to prevent the deserialization of dangerous types that can have malicious side effects with the runtime serializers such as the BinaryFormatter.

The author, on code-white.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the custom binders validated the raw strings or resolved types differently from the runtime's fallback binder, and returned null instead of throwing, so the runtime's own type loading still succeeded.

Impact

An attacker able to supply serialized data could bypass the binder's validation and deserialize a dangerous type, leading to remote code execution in both DevExpress and Exchange.

What the attacker needed

Ability to supply serialized data; vulnerable .NET app using a custom binder

The fix

Binders should resolve the type the same way the runtime does and throw on any unexpected type rather than returning null.

How it was found

  1. Set the assembly name and type name explicitly in the serialized object instead of using the normal type setter.
  2. Pass the assembly-qualified name of the dangerous type as the type name so the string check misses it.
  3. Add a custom assembly attribute containing a closing bracket so the binder's own parser gives up.
  4. Let the binder return null so the runtime fallback loads the type and deserialization proceeds.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

When .NET saves an object it writes down the name of the class and the file (assembly) it lives in, and when it loads the object back it looks those names up. A serialization binder is a small hook meant to check those names and refuse dangerous classes, but if the check reads the name differently from the loader, or gives up and returns nothing, the loader carries on and loads the dangerous class anyway. That lets an attacker who can supply serialized data run their own code on the server.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.