Skip to content

Enforce safe JSON deserialization in ServiceFabric - #1386

Open
Naiyuan Tian (nytian) wants to merge 1 commit into
mainfrom
nytian/fabric-security
Open

Enforce safe JSON deserialization in ServiceFabric#1386
Naiyuan Tian (nytian) wants to merge 1 commit into
mainfrom
nytian/fabric-security

Conversation

@nytian

Copy link
Copy Markdown
Contributor

Ensure the Service Fabric JSON formatter always uses the allowed-types binder. This prevents untrusted requests from deserializing arbitrary .NET types through type metadata. Tests are added.

Copilot AI lite review requested due to automatic review settings August 14, 2026 15:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens the Azure Service Fabric proxy’s JSON deserialization by ensuring a serialization binder is always applied when TypeNameHandling.All is enabled, preventing untrusted requests from deserializing arbitrary .NET types via $type metadata.

Changes:

  • Default Startup to an AllowedTypesSerializationBinder when no binder is provided, and always assign a binder to the JSON formatter settings.
  • Change FabricOrchestrationProviderSettings.JsonSerializationBinder so null restores the default allowed-types binder instead of disabling restrictions.
  • Update the corresponding binder-setting unit test expectation (but currently in a non-build/test project path).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Test/DurableTask.AzureServiceFabric.Tests/AllowedTypesSerializationBinderTests.cs Updates test to expect null binder assignment to restore the allowed-types binder (currently under Test/, not the active test/ project).
src/DurableTask.AzureServiceFabric/Service/Startup.cs Ensures a non-null binder is always applied to JsonFormatter.SerializerSettings.SerializationBinder.
src/DurableTask.AzureServiceFabric/FabricOrchestrationProviderSettings.cs Makes JsonSerializationBinder non-null by default and treats null as “reset to default binder”.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 225 to +230
[TestMethod]
public void Settings_BinderCanBeSetToNull()
public void Settings_NullBinderRestoresAllowedTypesBinder()
{
var providerSettings = new FabricOrchestrationProviderSettings();
providerSettings.JsonSerializationBinder = null;
Assert.IsNull(providerSettings.JsonSerializationBinder);
Assert.IsInstanceOfType(providerSettings.JsonSerializationBinder, typeof(AllowedTypesSerializationBinder));
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.

2 participants