Skip to content

Bring v3.14.1 servicing fixes to dev - #3518

Merged
andystaples merged 6 commits into
devfrom
andystaples-cherry-pick-v3-14-1-hotfix
Aug 19, 2026
Merged

andystaples merged 6 commits into
devfrom
andystaples-cherry-pick-v3-14-1-hotfix

Conversation

@andystaples

@andystaples andystaples commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Brings the changes released from the ADO hotfix/v3.14.1 branch onto dev for 3.15.0. This PR is no longer a straight cherry-pick: GitHub validation exposed a production regression in the released custom-token-source serialization path, so this branch also contains the correction.

  • hardens legacy ITokenSource deserialization with an explicit binder allowlist
  • preserves replay compatibility for built-in managed identity histories
  • uses the configured message serializer when the built-in HTTP activity reconstructs requests
  • restores end-to-end coverage for explicitly allowlisted custom token sources, including same-origin forwarding and cross-origin stripping
  • adds required test category metadata and uses public PyPI for the Python smoke test

Why this differs from the ADO release

The 3.14.1 hardening correctly required an explicit, non-default binder for custom ITokenSource roots. However, TaskHttpActivityShim reconstructed scheduled requests with the default JsonConvert serializer, discarding the binder that had been used when the request was scheduled. As a result, correctly allowlisted custom token sources failed at the built-in HTTP activity boundary.

This PR now reconstructs those requests through DurableTaskExtension.MessageDataConverter, using the application's configured binder consistently at both boundaries. The 3.14.1 security boundary remains intact: applications without an explicit binder still reject custom roots, resolved types must still be concrete ITokenSource implementations, and nested polymorphic type handling remains disabled.

Testing

  • net8.0: 10 serializer/security unit tests and 6 custom-token Durable HTTP E2E tests passed
  • net10.0: 10 serializer/security unit tests and 6 custom-token Durable HTTP E2E tests passed

## Problem

The in-process `DurableHttpRequest.TokenSource` converter supports a legacy `$type` payload format for custom `ITokenSource` implementations. That path resolved the supplied CLR type and deserialized the full object graph with `TypeNameHandling.Objects`, without an allowlist for the root type and while honoring nested type metadata. The newer discriminator-based `ManagedIdentityTokenSource` path was already fixed to a known type; the concern was limited to the legacy compatibility path.

This servicing change is based on the unchanged v3.14.0 release commit and bumps only the in-process extension to 3.14.1.

## Fix

- Continue accepting the built-in `ManagedIdentityTokenSource` through its current `kind` discriminator and legacy `$type` representation.
- Require custom token-source roots to use an explicitly configured non-default `ISerializationBinder`; the default binder is not accepted as an allowlist.
- Resolve custom root names through `BindToType`, then require the result to be a concrete, non-abstract `ITokenSource`.
- Emit custom root names through `BindToName` instead of persisting `AssemblyQualifiedName` directly.
- Deserialize custom token-source state with a cloned serializer configured with `TypeNameHandling.None`, so nested `$type` metadata cannot select runtime types.
- Route subclasses of `ManagedIdentityTokenSource` through the custom binder path rather than silently treating them as the built-in type.
- Parse assembly-qualified generic root names without splitting on commas inside generic argument brackets.

The intentional compatibility boundary is that built-in managed identity works without configuration, while custom implementations require an explicit binder allowlist. Concrete nested state continues to deserialize according to its declared type, but nested polymorphic metadata is ignored.

## In-flight compatibility and regression coverage

- v3.14.0 built-in managed-identity histories replay unchanged.
- Custom histories replay only with an explicit root-type binder; otherwise they fail safely.
- Persisted-payload tests cover both paths and prove nested derived type metadata is ignored under TypeNameHandling.Objects.
- Coverage is converter-level, not a separate old-host/new-host rolling-upgrade test.

## Rejected approaches

1. **Remove the legacy `$type` path entirely.** This prevents replay of all legacy payloads, including the fixed built-in managed-identity format and safely allowlisted custom implementations.
2. **Allow every concrete `ITokenSource`.** Interface assignability is not an allowlist; an attacker could still select a side-effectful implementation already loaded in the process.
3. **Allowlist only `ManagedIdentityTokenSource` with no custom path.** This is secure but unnecessarily removes the public custom extension point when the application already has a binder-based allowlist configuration surface.
4. **Apply an `ITokenSource`-only binder to every `$type` in the object graph.** Nested state...
Copilot AI lite review requested due to automatic review settings August 17, 2026 17:36

@bachuv Varshitha Bachu (bachuv) 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.

Approved, but please wait for all CI tests to pass before merging. Thanks!

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

Note

Copilot was unable to run its full agentic suite in this review.

Updates DurableHttpRequest token source JSON (de)serialization to be safer and more explicit around type handling, including backward compatibility paths, and adds tests for the supported/unsupported scenarios.

Changes:

  • Tightens ITokenSource serialization/deserialization to require an explicit SerializationBinder for custom token sources and to avoid emitting nested $type.
  • Adds unit coverage for managed identity, legacy history formats, and custom token sources with/without an allowed binder.
  • Bumps package patch version to 3.14.1.

Reviewed changes

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

File Description
test/FunctionsV2/Tests/Unit/DurableHttpRequestTests.cs Adds regression tests for token source round-tripping and legacy history deserialization.
src/WebJobs.Extensions.DurableTask/WebJobs.Extensions.DurableTask.csproj Increments patch version to publish the behavior change.
src/WebJobs.Extensions.DurableTask/DurableHttpRequest.cs Refactors token source converter to enforce binder usage for custom types and suppress $type emission except when explicitly allowed.

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

Copilot AI review requested due to automatic review settings August 19, 2026 16:06

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

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

Suppressed comments (4)

src/WebJobs.Extensions.DurableTask/DurableHttpRequest.cs:285

  • GetCustomTokenSourceBinder rejects any binder that derives from DefaultSerializationBinder because it uses is DefaultSerializationBinder. That prevents callers from safely subclassing DefaultSerializationBinder to implement an allowlist. Checking for the exact DefaultSerializationBinder type (or the known default instance) is safer while still enforcing "not the default binder".
            {
                if (serializer.SerializationBinder == null || serializer.SerializationBinder is DefaultSerializationBinder)
                {
                    throw new JsonSerializationException("Custom token sources require an explicitly configured serialization binder.");
                }

src/WebJobs.Extensions.DurableTask/DurableHttpRequest.cs:236

  • CreateManagedIdentityTokenSource uses optionsToken.ToObject<ManagedIdentityOptions>() without an explicit serializer. JToken.ToObject<T>() uses JsonSerializer.CreateDefault(), which respects JsonConvert.DefaultSettings (and could re-enable TypeNameHandling globally), undermining the goal of hardening deserialization. Consider explicitly deserializing options with TypeNameHandling=None regardless of ambient defaults.
                if (jsonObject.TryGetValue("options", out JToken optionsToken))
                {
                    ManagedIdentityOptions managedIdentityOptions = optionsToken.ToObject<ManagedIdentityOptions>();
                    return new ManagedIdentityTokenSource(resourceString, managedIdentityOptions);
                }

src/WebJobs.Extensions.DurableTask/DurableHttpRequest.cs:149

  • TokenSourceConverter.CanConvert is incorrect: objectType is a Type, so objectType is ITokenSource will always be false. Even though this converter is applied via attribute, the method should correctly report compatibility (and it may be used in other contexts later).
            public override bool CanConvert(Type objectType)
            {
                return objectType is ITokenSource;
            }

            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)

test/FunctionsV2/Tests/Unit/DurableHttpRequestTests.cs:146

  • This test currently throws because no serialization binder is configured (the converter rejects all non-managed-identity $type payloads without a custom binder), so it doesn't actually validate the "type does not implement ITokenSource" branch. Configure a binder for the deserialization path so the converter reaches the !typeof(ITokenSource).IsAssignableFrom(runtimeType) check.
                {
                    ["$type"] = typeof(UnsupportedType).AssemblyQualifiedName,
                });

            Assert.Throws<JsonSerializationException>(() => json.ToObject<DurableHttpRequest>());

Add required category traits to the servicing regression tests and use public PyPI for the Python smoke-test image.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f2f1ee44-0784-4508-b984-3ff2676f8a74
Copilot AI review requested due to automatic review settings August 19, 2026 16:20
@andystaples

andystaples commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor Author

This PR now intentionally diverges from the v3.14.1 commit released through ADO in production code and test assets.

The production difference corrects a regression found by GitHub E2E validation: TaskHttpActivityShim used the default JsonConvert serializer to reconstruct scheduled Durable HTTP requests, so it lost the explicitly configured binder and rejected otherwise valid custom ITokenSource implementations. The activity now uses the configured MessageDataConverter, preserving the binder allowlist without re-enabling nested polymorphic deserialization.

The test/configuration differences add the required xUnit category metadata, switch the Python smoke-test Dockerfile to public PyPI, and restore custom-token-source E2E coverage with a binder restricted to MockTokenSource.

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Suppressed comments (2)

src/WebJobs.Extensions.DurableTask/DurableHttpRequest.cs:236

  • optionsToken.ToObject<ManagedIdentityOptions>() uses a default JsonSerializer (potentially affected by JsonConvert.DefaultSettings, including TypeNameHandling). To keep legacy history parsing hardened, deserialize options with an explicit TypeNameHandling.None serializer.
                if (jsonObject.TryGetValue("options", out JToken optionsToken))
                {
                    ManagedIdentityOptions managedIdentityOptions = optionsToken.ToObject<ManagedIdentityOptions>();
                    return new ManagedIdentityTokenSource(resourceString, managedIdentityOptions);
                }

test/FunctionsV2/Tests/Unit/DurableHttpRequestTests.cs:132

  • This test name is misleading: with the current converter logic, a $type value that isn’t ManagedIdentityTokenSource is rejected first due to the missing non-default SerializationBinder, not specifically because the type doesn’t implement ITokenSource. Renaming the test makes the intent/coverage clearer.
        public void TokenSource_RejectsTypeThatDoesNotImplementInterface()

Use explicit authorization headers for forwarding tests and remove obsolete custom token source E2E cases now covered by binder-focused unit tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f2f1ee44-0784-4508-b984-3ff2676f8a74
Copilot AI review requested due to automatic review settings August 19, 2026 16:42

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Suppressed comments (4)

src/WebJobs.Extensions.DurableTask/DurableHttpRequest.cs:285

  • GetCustomTokenSourceBinder rejects any binder that inherits from DefaultSerializationBinder because it uses is DefaultSerializationBinder. That would block callers who implement an allowlist by subclassing DefaultSerializationBinder (still an explicit binder). Consider only rejecting the built-in default binder instance/type, not derived custom binders.
            private static ISerializationBinder GetCustomTokenSourceBinder(JsonSerializer serializer)
            {
                if (serializer.SerializationBinder == null || serializer.SerializationBinder is DefaultSerializationBinder)
                {
                    throw new JsonSerializationException("Custom token sources require an explicitly configured serialization binder.");
                }

src/WebJobs.Extensions.DurableTask/DurableHttpRequest.cs:167

  • ReadJson throws NotSupportedException for an unsupported kind value. For JSON conversion failures, Json.NET typically expects JsonSerializationException so callers can reliably catch/diagnose deserialization errors.
                if (jsonObject.TryGetValue("kind", out JToken kindValue))
                {
                    if (Enum.TryParse((string)kindValue, out TokenSourceType tokenSourceKind) &&
                        tokenSourceKind == TokenSourceType.AzureManagedIdentity)
                    {
                        return CreateManagedIdentityTokenSource(jsonObject);
                    }

                    throw new NotSupportedException($"The token source kind '{kindValue.ToString(Formatting.None)}' is not supported.");
                }

src/WebJobs.Extensions.DurableTask/DurableHttpRequest.cs:188

  • ReadJson throws NotSupportedException when neither kind nor $type is present. Since this is a malformed payload scenario, consider throwing JsonSerializationException for consistency with other failure paths and easier exception handling upstream.
                }

                throw new NotSupportedException("The token source kind is missing.");
            }

test/FunctionsV2/Tests/Unit/DurableHttpRequestTests.cs:141

  • This test name/intent no longer matches the behavior being validated: with the new converter logic, deserializing any non-managed-identity $type without a custom binder fails because the binder is missing (before the “does not implement interface” check). Either configure a binder that maps to UnsupportedType to validate the interface rejection, or rename the test to reflect the binder requirement.
        [Fact]
        [Trait("Category", PlatformSpecificHelpers.TestCategory)]
        public void TokenSource_RejectsTypeThatDoesNotImplementInterface()
        {
            JObject json = CreateRequestJson(
                new JObject
                {
                    ["$type"] = typeof(UnsupportedType).AssemblyQualifiedName,
                });

            Assert.Throws<JsonSerializationException>(() => json.ToObject<DurableHttpRequest>());
        }

@andystaples
andystaples marked this pull request as draft August 19, 2026 16:56
Restore custom token source end-to-end coverage with a strict test binder so the activity boundary regression remains covered.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f2f1ee44-0784-4508-b984-3ff2676f8a74
Copilot AI review requested due to automatic review settings August 19, 2026 18:23
@andystaples andystaples changed the title Cherry-pick v3.14.1 servicing hotfix to dev Bring v3.14.1 servicing fixes to dev Aug 19, 2026

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/WebJobs.Extensions.DurableTask/DurableHttpRequest.cs:153

  • TokenSourceConverter.CanConvert uses objectType is ITokenSource, but objectType is a Type, so this check is always false. While this converter is currently applied via a [JsonConverter] attribute, the CanConvert implementation is still incorrect and would prevent the converter from being selected if it were ever added via JsonSerializerSettings.Converters.

Consider updating CanConvert to test assignability from ITokenSource.


            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                JToken json = JToken.ReadFrom(reader);
                if (json.Type == JTokenType.Null)
                {

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f2f1ee44-0784-4508-b984-3ff2676f8a74
Copilot AI review requested due to automatic review settings August 19, 2026 18:36

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (2)

src/WebJobs.Extensions.DurableTask/DurableHttpRequest.cs:218

  • Managed identity options are serialized via JsonConvert.SerializeObject(...), which ignores the passed-in JsonSerializer and any hardened settings. If an app sets JsonConvert.DefaultSettings with TypeNameHandling enabled, this can accidentally emit $type inside options, undermining the intended "no nested polymorphic types" boundary. Serialize options using the safe serializer derived from the active JsonSerializer instead of the static JsonConvert helper.
                {
                    ISerializationBinder binder = GetCustomTokenSourceBinder(serializer);
                    binder.BindToName(value.GetType(), out string assemblyName, out string typeName);
                    if (string.IsNullOrWhiteSpace(typeName))
                    {

src/WebJobs.Extensions.DurableTask/DurableHttpRequest.cs:153

  • TokenSourceConverter.CanConvert is incorrect: objectType is a Type, so objectType is ITokenSource is always false. This makes the converter report it can't handle ITokenSource types (and can break if the converter is ever registered globally).

            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                JToken json = JToken.ReadFrom(reader);
                if (json.Type == JTokenType.Null)
                {

@andystaples
andystaples marked this pull request as ready for review August 19, 2026 18:50
@andystaples
andystaples merged commit 67c6377 into dev Aug 19, 2026
59 checks passed
@bachuv
Varshitha Bachu (bachuv) deleted the andystaples-cherry-pick-v3-14-1-hotfix branch August 19, 2026 22:07
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