[release/9.0-staging] [NRBF] Allow the users to decode System.Nullable<UserStruct>#118328
Merged
jeffhandley merged 4 commits intorelease/9.0-stagingfrom Aug 5, 2025
Merged
Conversation
…WithMembersAndTypes in the payload
This reverts commit 3636ebe.
adamsitnik
approved these changes
Aug 4, 2025
Contributor
|
Tagging subscribers to 'binaryformatter-migration': @adamsitnik, @bartonjs, @jeffhandley, @JeremyKuhne |
jeffhandley
approved these changes
Aug 4, 2025
Member
jeffhandley
left a comment
There was a problem hiding this comment.
This has my support for backport to .NET 9. Customer-blocking issue.
Member
|
/ba-g Build analysis showed only one known issue: wasm build failure in CI (dotnet/runtime#117017) |
Member
|
/ba-g This is a known issue |
Contributor
|
/ba-g This is a known issue! |
Contributor
|
/ba-g Trying again! This is a known issue! |
This was referenced Sep 9, 2025
This was referenced Sep 25, 2025
Closed
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #118276 to release/9.0-staging
/cc @adamsitnik
Customer Impact
Customers using
NrbfDecoderto decode a very specific payload that was generated by theBinaryFormatterwill fail with an exception about invalid payload.More details: The payload can be generated by the
BinaryFormatterfor a type with a nullable user-defined struct where the first occurrence of such struct is anull.BinaryFormatteris then fetching the field type (rather than instance type) and since it'sSystem.Nullable<$UserType>it's described as BinaryType.SystemClass rather thanBinaryType.Class. Since NrbfDecoder is restrictive to be secure by default, the input is rejected as for a "system record" the payload contains "non-system record".One of our first party customers is moving away from BinaryFormatter and they are currently blocked as they have hit this limitation during their migration process. The issue was reported internally.
Regression
Testing
A standalone and simple repro was identified and turned into a unit test. The test was failing without the fix, now it's passing.
Risk
Low. The
NrbfDecoderis now going to decode such payloads, but it's going to keep the record type as it was (SerializationRecordType.ClassWithMembersAndTypes, notSerializationRecordType.SystemClassWithMembersAndTypes).