Skip to content

Additional unsafe deserializers#349

Merged
MathiasVP merged 3 commits intomainfrom
additional-unsafe-deserializers
Apr 24, 2026
Merged

Additional unsafe deserializers#349
MathiasVP merged 3 commits intomainfrom
additional-unsafe-deserializers

Conversation

@chanel-y
Copy link
Copy Markdown

@chanel-y chanel-y commented Apr 14, 2026

Adding the unsafe deserializers available in csharp but now in powershell!

Weird thing about this PR is how it splits up the different kinds of .NET APIs are invoked in powershell:

InstanceDeserializerSink — Creates an object, then calls a method on it:

$fmt = New-Object System.Runtime.Serialization.Formatters.Soap.SoapFormatter
$fmt.Deserialize($stream) # ← sink is $stream

Requires tracking that $fmt was created as an unsafe type, then matching the method call on it.

StaticDeserializerSink — Call a static method directly on the type (no object creation):

[System.Windows.Markup.XamlReader]::Parse($xaml) # ← sink is $xaml

No New-Object involved — just [Type]::Method(). Needs different matching logic (check isStatic() + the type qualifier).

UnsafeConstructorSink — The constructor itself is the dangerous operation (not a follow-up method):

$r = New-Object System.Resources.ResourceReader -ArgumentList $pat

ResourceReader deserializes the resource file at construction time, so the constructor argument is the sink

Each of the deserializers is classified into of the above, except BinaryFormatter which is separate since it's still used by the BinaryFormatter query

Copy link
Copy Markdown
Collaborator

@MathiasVP MathiasVP left a comment

Choose a reason for hiding this comment

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

Slightly less API-graphy than I was hoping for, but it does the job so I don't see a reason not to get this merged. Great job, Chanel and Copilot!

We should investigate at some point whether API graphs can make these very syntax-driven predicates more general, but that does not need to be now.

@MathiasVP MathiasVP enabled auto-merge April 24, 2026 09:35
@MathiasVP MathiasVP merged commit 0ff3ae8 into main Apr 24, 2026
5 checks passed
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