Status: Approved with feedback | API Ref | Video
- Do we need a public API at all? It seems:
- The majority of the usages would be from the framework itself; very few external customers would use it.
- Before we make it a public API, we might want to keep it private to validate the APIs with internal usage first.
- The API won't be in .NET Framework 4.8 (implementation might), so we have more time anyways.
- We should rename the exception type and derive from
SerializationException- Code using binary serialization and data contract serialization is likely already handling this exception.
DeserializationBlockedException:SerializationException
- Should
StartDeserialization()be blocked too?- The attack vector is deliberately calling and leaking the token, thus effectively disabling many types
- We need to support recursive deserialization, so we can't prevent calling this API in general
- Ideally we'd prevent direct calls via reflection, but we don't have that mechanism in .NET Core.
ThrowOnDangerousDeserializationshould be renamed toThrowIfDeserializationInProgress- We need to figure out how individual gadgets/targets would get granular
checks. Presumably passing a
string-based switch toThrowIfDeserializationInProgresswould be good enough. - If
DeserializationTokenneeds to be class, we should hide the type and just returnIDisposable. In other words, the type would be useful to make this a struct. DeserializationBlockedExceptionshould probably follow the default patterns for constructors. The construction of the message with the switch name can be handled by the corresponding throw helper onSerializationInfo.
- Provide throw helper with switch
- Agree on default policy (on/off)
- Agree on whether or not we make these APIs public in .NET Core 3.0
- We should distill a list with 3rd party serializers what would be good customers (i.e. are baking type information into the payload).