Repository navigation
.Net: Improve OpenAPI HTTP connection handling - #14570
SergeyMenshykh merged 5 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The new owning HTTP clients lack a disposal path, potentially retaining connection pools and sockets.
1 open finding
What changed in this PR
Improves OpenAPI SSRF protection by binding validated DNS addresses to outgoing connections while preserving host identity and custom clients.
Changes:
- Propagates validated DNS addresses to HTTP requests.
- Adds separate pinned and unpinned connection pools.
- Adds connection, TLS, pooling, and client-preservation tests.
| File | Description |
|---|---|
PublicNetworkAddressValidator.cs |
Returns validated DNS addresses. |
ServerUrlValidatorTests.cs |
Verifies validation results. |
OpenApiHttpClientProviderTests.cs |
Tests pinning, pooling, TLS, and custom clients. |
ServerUrlValidator.cs |
Propagates validated addresses. |
RestApiOperationRunner.cs |
Attaches addresses to requests. |
OpenApiKernelPluginFactory.cs |
Uses the new default HTTP client. |
OpenApiHttpClientProvider.cs |
Implements pinned connection handling. |
OpenApiFunctionExecutionParameters.cs |
Documents pinning limitations. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (1 commit(s)): 1ce41a37edc5
Model: gpt-5.6-sol
Overview
The PR carries validated DNS results into the built-in .NET client, separates pinned and unchecked socket pools, preserves the HTTP/TLS hostname, and retains redirect and certificate checks. The regression tests cover direct exact-address routing, pool separation, SNI, and validator propagation. Three Medium risks remain: the newly owned handlers lack a deterministic lifetime, sequential address attempts can prevent fallback to a healthy endpoint, and manifest-based imports lose document-session cookies when they create a second default client for operations.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
3 verified findings remained after source verification (3 medium) across 2 files. Details are attached to the affected lines below.
Affected areas: dotnet/src/Functions/Functions.OpenApi/OpenApiHttpClientProvider.cs, dotnet/src/Functions/Functions.OpenApi/OpenApiKernelPluginFactory.cs
Reuse the default handler across clients while retaining separate connection pools. Add client disposal and connection reuse coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use staggered connection attempts with a single completion wait. Preserve cancellation and connection ownership, and add fallback coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Motivation and Context
Improve consistency of the built-in OpenAPI HTTP client while preserving request identity and existing customization points.
Description
Refine connection handling and internal validation-result propagation. Preserve caller-supplied clients and existing redirect behavior. Add regression coverage for connection selection, pooling, and HTTPS behavior.