Skip to content

Add RemoteOrchestrationTypeBinder for stricter type handling#1344

Closed
AnatoliB wants to merge 1 commit intomainfrom
anatolib/codeql-fix-37181654
Closed

Add RemoteOrchestrationTypeBinder for stricter type handling#1344
AnatoliB wants to merge 1 commit intomainfrom
anatolib/codeql-fix-37181654

Conversation

@AnatoliB
Copy link
Copy Markdown
Collaborator

@AnatoliB AnatoliB commented May 1, 2026

Copilot AI review requested due to automatic review settings May 1, 2026 01:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Introduces a strict JSON.NET serialization binder for the Azure Service Fabric remote orchestration client to constrain which $type values can be resolved, reducing risk from unsafe type handling in remote RPC payload serialization settings.

Changes:

  • Added RemoteOrchestrationTypeBinder (allowlist-based ISerializationBinder) for DurableTask remote RPC payloads.
  • Updated RemoteOrchestrationServiceClient.PutJsonAsync to use TypeNameHandling.Auto and the new strict binder.
  • Added unit tests intended to validate round-trip behavior and rejection of non-allowlisted types.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/DurableTask.AzureServiceFabric/Remote/RemoteOrchestrationTypeBinder.cs New strict binder that only permits types from DurableTask.Core, DurableTask.AzureServiceFabric, and Dictionary<string,string>.
src/DurableTask.AzureServiceFabric/Remote/RemoteOrchestrationServiceClient.cs Switches JSON formatter to TypeNameHandling.Auto and applies the strict binder.
Test/DurableTask.AzureServiceFabric.Tests/RemoteOrchestrationTypeBinderTests.cs Adds tests for binder allowlist and rejection behavior (but currently placed outside the solution’s active test projects).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +24 to +32
[TestClass]
public class RemoteOrchestrationTypeBinderTests
{
// Mirrors the production formatter settings configured in RemoteOrchestrationServiceClient.PutJsonAsync.
static readonly JsonSerializerSettings RoundTripSettings = new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Auto,
SerializationBinder = new RemoteOrchestrationTypeBinder()
};
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

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

This test file is under Test/ (capital T), but the solution’s MSTest projects live under test/ (lowercase) and DurableTask.AzureServiceFabric.Tests.csproj is at test/DurableTask.AzureServiceFabric.Tests/…. As-is, this file won’t be compiled or executed by CI. Move it into test/DurableTask.AzureServiceFabric.Tests/ (or update the test project to include it) so the new binder behavior is actually validated.

Copilot uses AI. Check for mistakes.
Comment on lines +84 to +97
public void RejectsNonAllowlistedRootType()
{
string json = "{\"$type\":\"System.IO.FileInfo, System.Private.CoreLib\",\"OriginalPath\":\"c:\\\\evil\"}";
Assert.ThrowsException<JsonSerializationException>(
() => JsonConvert.DeserializeObject<object>(json, RoundTripSettings));
}

[TestMethod]
public void RejectsNonAllowlistedNestedType()
{
string json = "{\"$type\":\"DurableTask.Core.History.ExecutionStartedEvent, DurableTask.Core\","
+ "\"Tags\":{\"$type\":\"System.Collections.Generic.SortedDictionary`2[[System.String, System.Private.CoreLib],[System.String, System.Private.CoreLib]], System.Collections\"}}";
Assert.ThrowsException<JsonSerializationException>(
() => JsonConvert.DeserializeObject<HistoryEvent>(json, RoundTripSettings));
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

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

These payloads hard-code .NET (Core) assembly names (System.Private.CoreLib, System.Collections). The DurableTask.AzureServiceFabric.Tests project targets net48, where these types live in different assemblies, so the test will fail once it’s included in the test project. Consider constructing the $type strings using typeof(FileInfo).Assembly.GetName().Name / typeof(SortedDictionary<,>).Assembly.GetName().Name (or otherwise avoiding framework-specific assembly names).

Copilot uses AI. Check for mistakes.
@AnatoliB AnatoliB closed this May 1, 2026
@AnatoliB AnatoliB deleted the anatolib/codeql-fix-37181654 branch May 1, 2026 06:01
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