Skip to content
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

Add deserialization type denylist #242

Merged
merged 28 commits into from
Aug 16, 2021

Conversation

to11mtm
Copy link
Member

@to11mtm to11mtm commented Jul 17, 2021

First step of resolving #226 and #239 . For now this just looks for the types we know are a bad idea and throws an exception if we encounter them.

@Aaronontheweb I won't have time to get this finished in the next week but hopefully you or @Arkatufus can take it from here.

Notes:

  • Added a String->Type cache to TypeSerializer to avoid penalties on repeatedly traversing the type hierarchy
  • I'm not sure how to handle traversing the type hierarchy for NetStandard 1.6 offhand. Probably will want to either take care of that or deprecate 1.6 support.

Aaronontheweb and others added 21 commits August 11, 2017 11:34
…net#69) (akkadotnet#70)

* add option for not publishing symbols for production release

* bad folder name
Hyperion v0.9.6 master release
Hyperion v0.9.7 production release
Version 0.10.2 release
Version 0.11.0 Release
@@ -132,19 +144,82 @@ private static Type GetTypeFromManifestName(Stream stream, DeserializerSession s
});
}

public static bool disallowUnsafeTypes = true;

private static ReadOnlyCollection<string> unsafeTypesDenySet =
Copy link
Member Author

Choose a reason for hiding this comment

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

This list was amalgamated from:

@@ -132,19 +144,82 @@ private static Type GetTypeFromManifestName(Stream stream, DeserializerSession s
});
}

public static bool disallowUnsafeTypes = true;
Copy link
Member Author

Choose a reason for hiding this comment

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

So, you can't -really- get to this since TypeEx is internal. This should probably be either moved or left out (because really, -why- would you want to do any of these? it's just a bad idea.)

{
//System.Diagnostics.Process p = new Process();
var serializer = new Hyperion.Serializer();
var di =new System.IO.DirectoryInfo(@"c:\");
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if this unit test will play well in other OS runs... May need to make this something more platform friendly.

Copy link
Contributor

@Arkatufus Arkatufus left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the contribution :)

@Aaronontheweb
Copy link
Member

Merging in #250 and then running some benchmarks on this PR

{
if (type.IsValueType)
return false;
var currentBase = type.BaseType;
Copy link
Member Author

Choose a reason for hiding this comment

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

should we actually start this off with type, just to be safe?

Copy link
Member

Choose a reason for hiding this comment

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

In terms of security scanning?

Copy link
Member

Choose a reason for hiding this comment

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

If that's your question, then yes I would - want to work our way from bottom to top

Copy link
Contributor

Choose a reason for hiding this comment

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

No, its fine, its the while...loop check that needs to be changed

Copy link
Member

Choose a reason for hiding this comment

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

Ah ok, I misunderstood what was being asked here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants