Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BinaryFormatter removal from .NET 9 is complete #106240

Closed
terrajobst opened this issue Aug 12, 2024 · 3 comments
Closed

BinaryFormatter removal from .NET 9 is complete #106240

terrajobst opened this issue Aug 12, 2024 · 3 comments
Labels
area-Meta binaryformatter-migration Issues related to the removal of BinaryFormatter and migrations away from it breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. discussion
Milestone

Comments

@terrajobst
Copy link
Member

terrajobst commented Aug 12, 2024

As announced earlier, starting with .NET 9, we no longer include an implementation of BinaryFormatter in the runtime (.NET Framework remains unchanged). The APIs are still present, but their implementation always throws an exception, regardless of project type. Hence, setting the existing backwards compatibility flag is no longer sufficient to use BinaryFormatter.

  • We published the BinaryFormatter migration guide. We'd appreciate if could give it a read and give us feedback by filling issues in the dotnet/docs repo.
  • If you experience issues related to BinaryFormatter's removal not addressed in this migration guide, please file an issue in the dotnet/runtime repo and indicate that the issue is related to the removal of BinaryFormatter.

Why was it removed?

Docs

The primary reason is that BinaryFormatter is unsafe. Any deserializer, binary or text, that allows its input to carry information about the objects to be created is a security problem waiting to happen. There is a common weakness enumeration (CWE) that describes the issue: CWE-502 "Deserialization of Untrusted Data". BinaryFormatter is such a deserializer. We also cover this in the BinaryFormatter security guide.

What are my options to move forward?

Docs

You have two options to address the removal of BinaryFormatter's implementation:

  1. Migrate away from BinaryFormatter. We strongly recommend you to investigate options to stop using BinaryFormatter due to the associated security risks. The BinaryFormatter migration guide lists several options.

  2. Keep using BinaryFormatter. If you need to continue using BinaryFormatter in .NET 9, you need to depend on the unsupported System.Runtime.Serialization.Formatters NuGet package, which restores the unsafe legacy functionality and replaces the throwing implementation.

@terrajobst terrajobst added area-Meta breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. binaryformatter-migration Issues related to the removal of BinaryFormatter and migrations away from it labels Aug 12, 2024
@dotnet-policy-service dotnet-policy-service bot added the needs-breaking-change-doc-created Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet label Aug 12, 2024

This comment was marked as resolved.

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Aug 12, 2024

This comment was marked as resolved.

This comment was marked as resolved.

@terrajobst terrajobst removed untriaged New issue has not been triaged by the area owner needs-breaking-change-doc-created Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet labels Aug 12, 2024
@terrajobst terrajobst added this to the 9.0.0 milestone Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Meta binaryformatter-migration Issues related to the removal of BinaryFormatter and migrations away from it breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. discussion
Projects
None yet
Development

No branches or pull requests

2 participants