Skip to content

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Aug 4, 2025

Backport of #118276 to release/9.0-staging

/cc @adamsitnik

Customer Impact

  • Customer reported
  • Found internally

Customers using NrbfDecoder to decode a very specific payload that was generated by the BinaryFormatter will fail with an exception about invalid payload.

More details: The payload can be generated by the BinaryFormatter for a type with a nullable user-defined struct where the first occurrence of such struct is a null. BinaryFormatter is then fetching the field type (rather than instance type) and since it's System.Nullable<$UserType> it's described as BinaryType.SystemClass rather than BinaryType.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

  • Yes
  • No

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 NrbfDecoder is now going to decode such payloads, but it's going to keep the record type as it was (SerializationRecordType.ClassWithMembersAndTypes, not SerializationRecordType.SystemClassWithMembersAndTypes).

@adamsitnik adamsitnik added the Servicing-consider Issue for next servicing release review label Aug 4, 2025
@adamsitnik adamsitnik added this to the 9.0.x milestone Aug 4, 2025
@adamsitnik adamsitnik added binaryformatter-migration Issues related to the removal of BinaryFormatter and migrations away from it area-System.Formats.Nrbf labels Aug 4, 2025
Copy link
Contributor

Tagging subscribers to 'binaryformatter-migration': @adamsitnik, @bartonjs, @jeffhandley, @JeremyKuhne

Copy link
Member

@jeffhandley jeffhandley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has my support for backport to .NET 9. Customer-blocking issue.

@jeffhandley jeffhandley added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Aug 5, 2025
@jeffhandley
Copy link
Member

/ba-g Build analysis showed only one known issue: wasm build failure in CI (dotnet/runtime#117017)

@adamsitnik
Copy link
Member

/ba-g This is a known issue

@riarenas
Copy link
Contributor

riarenas commented Aug 5, 2025

/ba-g This is a known issue!

@riarenas
Copy link
Contributor

riarenas commented Aug 5, 2025

/ba-g Trying again! This is a known issue!

This was referenced Sep 25, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Sep 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Formats.Nrbf binaryformatter-migration Issues related to the removal of BinaryFormatter and migrations away from it Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants