-
-
Notifications
You must be signed in to change notification settings - Fork 337
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 is insecure and strongly cautioned against #2607
Comments
I think the fix here is pretty simple. Pretty sure you can seamlessly replace the two spots it's used with: DataContractSerializer typeSerializer = new DataContractSerializer(typeof(Type));
typeSerializer.WriteObject(stream, data.GetType());
DataContractSerializer objectSerializer = new DataContractSerializer(data.GetType());
objectSerializer.WriteObject(stream, GetAsSerializable(data)); and DataContractSerializer typeSerializer = new DataContractSerializer(typeof(Type));
Type dataType = (Type)typeSerializer.ReadObject(dataStream);
DataContractSerializer objectSerializer = new DataContractSerializer(dataType);
object data2 = objectSerializer.ReadObject(dataStream); for serialization/deserialization, respectively. |
So the way this initially surfaced was that
Looking at this stack trace in more detail, though, we can see that this is actually coming from a COM interop call here into some WPF libraries directly. Following the stack trace down, we eventually come to this method which we can see does, in fact, use Anyway, suffice to say: I'd recommend reopening this because this is still going to cause crashes out of the box when upgrading to net8.0, but it's a bigger issue than I initially realized and will require some thought to fix. cc/ @cwensley |
Hey @jonko0493, thanks for digging into this! I would recommend opening an issue at http://github.com/dotnet/wpf instead, as there's nothing we can do to fix it here. Cheers, |
@cwensley yeah, I was starting to think this might be something to talk to the .NET folks about. I'll reach out to them :) |
Looks like they have an open issue about it here: dotnet/wpf#1131 Seems that they were planning to remove it in the .NET 5 timeline but never got around to it. |
Not a bug, so eschewing the template for now. The
DragDropLib
uses theBinaryFormatter
class. The .NET folks recommend against this strongly and have even begun disabling it in more recent versions of .NET. It looks like we only use it in this one place, so it shouldn't be super hard to move off of, I'd guess.The text was updated successfully, but these errors were encountered: