Skip to content

Conversation

@layomia
Copy link
Contributor

@layomia layomia commented Sep 22, 2020

Also prevents the serializer from calling parameterized ctors with signature .ctor(SerializationInfo, StreamingContext).

FYI @GrabYourPitchforks, @eiriktsarpalis

@layomia layomia added this to the 6.0.0 milestone Sep 22, 2020
@layomia layomia requested a review from steveharter September 22, 2020 23:43
@layomia layomia requested a review from jozkee as a code owner September 22, 2020 23:43
@layomia layomia self-assigned this Sep 22, 2020
@GrabYourPitchforks
Copy link
Member

Given time I imagine we'll also want to deny the types Assembly, MethodInfo, and a whole slew of reflection-related things. Not really needed for this PR, but it would be interesting to think about whether the solution here might scale to capturing all of those. At the very least, in this theoretical future world, we'd want to update the exception message to avoid suggesting that every such type might lead to security problems.

Copy link
Member

@eiriktsarpalis eiriktsarpalis left a comment

Choose a reason for hiding this comment

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

Is this getting backported for 5.0? If not, wouldn't this be a 6.0 breaking change for the hypothetical customer code that relies on SerializationInfo?

@layomia
Copy link
Contributor Author

layomia commented Sep 23, 2020

it would be interesting to think about whether the solution here might scale to capturing all of those. At the very least, in this theoretical future world, we'd want to update the exception message to avoid suggesting that every such type might lead to security problems.

wrt. adapting the error message appropriately, we could add a new internal TypeDisallowReason enum (or something similar) which would be a parameter for a ctor on UnsupportedTypeConverter which would inform what message to spit out. Hopefully any further scalability issue can be worked out.

@layomia
Copy link
Contributor Author

layomia commented Sep 23, 2020

Is this getting backported for 5.0? If not, wouldn't this be a 6.0 breaking change for the hypothetical customer code that relies on SerializationInfo?

This change won't be a breaking change in 6.0, so we don't need to port it to 5.0. The Type and SerializationInfo types are already not (de)serializable, due to Type already being explicitly disallowed (both ctors on SerializationInfo take a Type, and there is serializable a Type member on SerializationInfo). This change only makes the exception message clearer when deserializing SerializationInfo and when disallowing .ctor(SerializationInfo, StreamingContext) from being invoked.

@layomia
Copy link
Contributor Author

layomia commented Sep 24, 2020

Test failures appear unrelated - 2 timeouts:

runtime (Libraries Test Run release coreclr Linux x64 Debug) Cancelled after 150m

runtime (Libraries Test Run release mono Linux x64 Debug) Cancelled after 149m

@layomia layomia merged commit dbbce43 into dotnet:master Sep 24, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
@layomia layomia deleted the invalid_types branch May 18, 2021 07:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants