Skip to content

Remove BinaryFormatter usage from SettingsPropertyValue #39295

Closed

Description

@GrabYourPitchforks

Ref:

using (MemoryStream ms = new MemoryStream((byte[])SerializedValue))
{
value = (new BinaryFormatter()).Deserialize(ms);
}

using (MemoryStream ms = new MemoryStream(buffer))
{
return (new BinaryFormatter()).Deserialize(ms);
}

using (MemoryStream ms = new MemoryStream())
{
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(ms, _value);
return ms.ToArray();
}

This issue tracks the removal and replacement of this code per the BinaryFormatter obsoletion plan.

For context: Reading from local configuration is generally perceived to be a "safe" operation. However, we have seen cases where the config APIs are used in multi-tenant environments, reading values from arbitrary XML files. The same thing hit ResourceReader a few years back. A popular web service allowed non-admins to upload .resx files, and when the web service tried parsing it it allowed RCE within the context of the service.

Activity

  1. added this to the Future milestone on Jul 14, 2020
  2. added
    untriaged
    on Jul 14, 2020
  3. removed
    untriaged
    on Jul 14, 2020
  4. ghost added
    needs-further-triage
    on Feb 10, 2021
  5. modified the milestones: Future, 6.0.0 on Feb 10, 2021
  6. removed
    needs-further-triage
    on Feb 10, 2021
  7. pgovind commented on Feb 10, 2021

    @pgovind

    I think this is a fairly easy library to turn off binary formatter support. Here's my proposal:

    There already exists a SettingsSerializeAs.Xml enum. So, let's mark SettingsSerializeAs.Binary as Obsolete for .NET 6. Further, I want to throw an exception when SettingsSerializeAs.Binary is used unless EnableUnsafeBinaryFormatterSerialization is set in the csproj.

    @GrabYourPitchforks, @ericstj, area-owners, thoughts?

  8. ghost added
    in-pr
    on Apr 1, 2021
  9. ghost removed
    in-pr
    on May 13, 2021
  10. ghost locked as resolved and limited conversation to collaborators on Jun 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions