fix: bound YAML anchor/alias expansion to prevent OOM (billion laughs) - #3000
Merged
Vincent Biret (baywet) merged 3 commits intoAug 11, 2026
Merged
Conversation
The YAML reader converts the SharpYaml node graph - a DAG in which aliases share a single instance - into a System.Text.Json JsonNode tree, allocating a fresh node per path. Because JsonNode is single-parent, shared aliases must be duplicated, so a tiny document with nested anchors/aliases expands exponentially and exhausts process memory (CWE-400, uncontrolled resource consumption). Add a conversion budget to YamlConverter.ToJsonNode that caps the total materialized node count (5,000,000) and nesting depth (64, mirroring the System.Text.Json default already enforced on the JSON reader path). On breach it throws OpenApiReaderException, which OpenApiYamlReader.Read converts into an OpenApiDiagnostic error instead of allowing an OOM. Public API is unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 022bbd4f-e5e7-447a-bcdf-b2a4efaf75c3
Expose YamlConverter.MaxDepth and MaxNodeCount as public static properties (defaulting to DefaultMaxDepth=64 and DefaultMaxNodeCount=5,000,000) so consumers can raise the limits for legitimately large/deep documents or lower them to fail faster on known-small inputs, without needing a library change. Setters validate that the value is greater than zero. Public API entries added. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 022bbd4f-e5e7-447a-bcdf-b2a4efaf75c3
Vincent Biret (baywet)
requested changes
Aug 10, 2026
Vincent Biret (baywet)
approved these changes
Aug 10, 2026
Vincent Biret (baywet)
left a comment
Member
There was a problem hiding this comment.
Thank you for making the changes!
Vincent Biret (baywet)
added a commit
that referenced
this pull request
Aug 11, 2026
fix: bound YAML anchor/alias expansion to prevent OOM (billion laughs) (#3000)
This was referenced Aug 11, 2026
Copilot AI
added a commit
that referenced
this pull request
Aug 12, 2026
…on laughs) Ports the fix merged on main (#3000) to the support/v1 reader, which walks the SharpYaml node graph directly. Aliases share a single source node, so a tiny document expands exponentially when materialized into independent OpenApi any trees, exhausting process memory (CWE-400). Adds a per-parse node budget enforced by ParsingContext and a nesting depth limit enforced while materializing any values. Limits are configurable through the new OpenApiReaderLimits type and default to 5,000,000 nodes and depth 64 (mirroring the System.Text.Json default) as on main. Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
This was referenced Aug 12, 2026
Merged
Merged
19 tasks
This was referenced Aug 12, 2026
This was referenced Aug 17, 2026
Roman Bolshakov (rombolshak)
pushed a commit
to rombolshak/ahlcg
that referenced
this pull request
Aug 18, 2026
…hers (#537) Updated [Microsoft.AspNetCore.Identity.EntityFrameworkCore](https://github.com/dotnet/dotnet) from 10.0.10 to 10.0.11. <details> <summary>Release notes</summary> _Sourced from [Microsoft.AspNetCore.Identity.EntityFrameworkCore's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.AspNetCore.OpenApi](https://github.com/dotnet/dotnet) from 10.0.10 to 10.0.11. <details> <summary>Release notes</summary> _Sourced from [Microsoft.AspNetCore.OpenApi's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.EntityFrameworkCore.Design](https://github.com/dotnet/dotnet) from 10.0.10 to 10.0.11. <details> <summary>Release notes</summary> _Sourced from [Microsoft.EntityFrameworkCore.Design's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.EntityFrameworkCore.InMemory](https://github.com/dotnet/dotnet) from 10.0.10 to 10.0.11. <details> <summary>Release notes</summary> _Sourced from [Microsoft.EntityFrameworkCore.InMemory's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Pinned [Microsoft.Extensions.Http.Resilience](https://github.com/dotnet/extensions) at 10.9.0. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.Http.Resilience's releases](https://github.com/dotnet/extensions/releases)._ ## 10.9.0 Version 10.9.0 is headlined by changes in these areas: * **AI:** New experimental routing APIs center on the abstract `RoutingChatClient` base class, with `SemanticRoutingChatClient` as a concrete semantic-routing implementation. Separately, the abstract `FailoverChatClient` specialization and its concrete `OrderedFailoverChatClient` implementation add failover routing. * **AI Evaluation:** The generated report gains redesigned Overview, Cases, History, and Comparison views. * **ASP.NET Core and HTTP diagnostics:** The release adds HTTP request latency log enrichment and fixes configuration binding, response-body logging, request-path redaction, and resilience package version handling. * **Source-generated logging and service discovery:** Fixes cover classification type qualification, thread-local state cleanup, and DNS query suffix handling. ## Experimental API Changes ### New Experimental APIs * New experimental API: HTTP request latency log enrichment (`EXTEXP0013`) #7602 * New experimental API: Chat client routing and failover (`MEAI001`) #7662 ## What's Changed ### AI (`Microsoft.Extensions.AI`, `Microsoft.Extensions.AI.Abstractions`, and `Microsoft.Extensions.AI.OpenAI`) * Add extensible chat client routing #7662 by @joshuajyue (co-authored by @Copilot) * Pass the request's options to the selected client #7685 by @joshuajyue (co-authored by @jozkee @Copilot) * AI.Abstractions: fix ExcludeFromSchema dropped under concurrent AIFunction creation #7677 by @jozkee (co-authored by @Copilot) * Cap OpenAI dependency version ([b10f9c0](dotnet/extensions@b10f9c0)) by @jeffhandley (co-authored by @Copilot) **Note: Microsoft.Extensions.AI.OpenAI constrains its dependency for OpenAI to 2.12.x, preventing OpenAI updates to 2.13.0+ due to an incompatibility. We expect to release Microsoft.Extensions.AI.OpenAI version 10.9.1 during the week of August 17 to address this issue.** ### HTTP Resilience and Diagnostics (`Microsoft.Extensions.Http.Resilience` and `Microsoft.Extensions.Http.Diagnostics`) * Fix Grpc.Net.ClientFactory version range check - Fixes #7565 #7566 by @Ghost93 * Fix response body logging under debugger #7678 by @Rimobul * Redact outgoing path when route is unknown #7687 by @Rimobul * Fix HTTP client logging config binding #7691 by @Rimobul ### ASP.NET Core Extensions (`Microsoft.AspNetCore.Diagnostics.Middleware`) * Rename HttpLatencyTelemetry extensions class and drop redundant TFM guard #7645 by @EasyL0ver (co-authored by @Copilot) * Add HTTP request latency log enricher (experimental) #7602 by @EasyL0ver (co-authored by @Copilot) ### Logging Source Generator (`Microsoft.Gen.Logging`) * [Microsoft.Gen.Logging] Clear thread-local state when logging throws #7682 by @Rimobul * [Microsoft.Gen.Logging] Fully qualify classification types #7689 by @Rimobul ### AI Evaluation (`Microsoft.Extensions.AI.Evaluation.Reporting`) * [Microsoft.Extensions.AI.Evaluation.Reporting] Evaluation report redesign #7609 by @grafanaKibana ### Project Templates (`Microsoft.McpServer.ProjectTemplates`) * Remove MCP server project template #7680 by @jeffhandley (co-authored by @Copilot) ... (truncated) ## 10.8.4 This servicing update refreshes the .NET AI project templates ahead of the July 30, 2026 retirement of GitHub Models — removing the GitHub Models provider option and updating template dependencies. As a result, both the AI Chat Web (`aichatweb`) and AI Agent Web API (`aiagent-webapi`) templates now **require** the AI service provider to be chosen explicitly via `--provider`; there is no longer a default. One of the following must be selected: - `--provider azureopenai` — Azure OpenAI - `--provider ollama` — Ollama (for local development) - `--provider openai` — OpenAI Platform ## Packages in this release | Package | Version | |---|---| | Microsoft.Extensions.AI.Templates | 10.8.4-preview.3.26379.3 | | Microsoft.Agents.AI.ProjectTemplates | 1.13.0-preview.1.26379.3 | ## What's Changed ### Project templates - **Removed the GitHub Models provider** from the AI Chat Web and AI Agent Web API templates, ahead of [GitHub Models being fully retired on July 30, 2026](https://github.blog/changelog/2026-07-01-github-models-is-being-fully-retired-on-july-30-2026/). The `--provider` option is now required with no default ([#7667](dotnet/extensions#7667)). - Updated AI template dependencies — bumped `Aspire.Hosting.AppHost` to `13.4.6` and `CommunityToolkit.VectorData.SqliteVec` to `1.0.0-preview.4` (aligned `System.Linq.AsyncEnumerable` to `10.0.9`), replacing earlier workaround package pins ([#7639](dotnet/extensions#7639)). ## Full Changelog - dotnet/extensions@v10.8.3...v10.8.4 ## 10.8.3 ## Packages in this release | Package | Version | |---|---| | Microsoft.Extensions.AI | 10.8.3 | | Microsoft.Extensions.AI.Abstractions | 10.8.3 | | Microsoft.Extensions.AI.OpenAI | 10.8.3 | ## Experimental API Changes ### Experimental API behavior updates - Updated serialization behavior for experimental `ToolApprovalRequestContent.RequiresConfirmation` so it no longer leaks into consumer source-generated `AIContent` JSON metadata unless approval APIs are intentionally used ([#7659](dotnet/extensions#7659)). ## What's Changed ### AI abstractions and serialization - Fixed MEAI001 leakage from `RequiresConfirmation` in source-generated `AIContent` contexts by using an internal JSON-included backing member while keeping the public experimental member ignored for source-generation metadata ([#7659](dotnet/extensions#7659)). ## Test Improvements - Added stabilization regression coverage to verify consumer source-generated `List<AIContent>` contexts compile and round-trip without requiring MEAI001 suppression ([#7659](dotnet/extensions#7659)). ## Full Changelog - dotnet/extensions@v10.8.2...v10.8.3 ## 10.8.2 This servicing release updates Microsoft.Extensions.VectorData.ConformanceTests to 10.8.2 and includes targeted test framework migration fixes. ## Packages in this release | Package | Version | Note | |---------|---------|---------| | Microsoft.Extensions.VectorData.Abstractions | 10.8.2 | Published August 7, 2026 | | Microsoft.Extensions.VectorData.ConformanceTests | 10.8.2 | | **Update: August 7, 2026** The Microsoft.Extensions.VectorData.Abstractions package was initially excluded from this release by mistake. Because Microsoft.Extensions.VectorData.ConformanceTests has a dependency on Microsoft.Extensions.VectorData.Abstractions, that led to failures when updating to Microsoft.Extensions.VectorData.ConformanceTests 10.8.2. Microsoft.Extensions.VectorData.Abstractions was published August 7, 2026 to resolve that issue. ## What's Changed ### AI * Move Microsoft.Extensions.VectorData.ConformanceTests to xUnit 3 #7636 by @adamsitnik (co-authored by @Copilot) ## Acknowledgements * @roji reviewed pull requests **Full Changelog**: dotnet/extensions@v10.8.1...v10.8.2 ## 10.8.1 This servicing release updates the Microsoft.Extensions.AI, Microsoft.Extensions.AI.Abstractions, and Microsoft.Extensions.AI.OpenAI packages to 10.8.1 with two targeted fixes: correct tool-call/tool-result ordering when resuming approval-gated functions with service-managed chat history, and preservation of the OpenAI Responses reasoning item id for stateless (store=false) encrypted reasoning. ## Packages in this release | Package | Version | |---------|---------| | Microsoft.Extensions.AI | 10.8.1 | | Microsoft.Extensions.AI.Abstractions | 10.8.1 | | Microsoft.Extensions.AI.OpenAI | 10.8.1 | ## What's Changed ### AI * Fix FICC tool_calls/tool ordering with approvals and service-managed chat history #7617 by @westey-m * Roundtrip OpenAI Responses reasoning item id for stateless (store=false) encrypted reasoning #7629 by @rogerbarreto (co-authored by @tarekgh) ## Acknowledgements * @jozkee reviewed pull requests **Full Changelog**: dotnet/extensions@v10.8.0...v10.8.1 Commits viewable in [compare view](dotnet/extensions@v10.8.0...v10.9.0). </details> Pinned [Microsoft.Extensions.ServiceDiscovery](https://github.com/dotnet/extensions) at 10.9.0. <details> <summary>Release notes</summary> _Sourced from [Microsoft.Extensions.ServiceDiscovery's releases](https://github.com/dotnet/extensions/releases)._ ## 10.9.0 Version 10.9.0 is headlined by changes in these areas: * **AI:** New experimental routing APIs center on the abstract `RoutingChatClient` base class, with `SemanticRoutingChatClient` as a concrete semantic-routing implementation. Separately, the abstract `FailoverChatClient` specialization and its concrete `OrderedFailoverChatClient` implementation add failover routing. * **AI Evaluation:** The generated report gains redesigned Overview, Cases, History, and Comparison views. * **ASP.NET Core and HTTP diagnostics:** The release adds HTTP request latency log enrichment and fixes configuration binding, response-body logging, request-path redaction, and resilience package version handling. * **Source-generated logging and service discovery:** Fixes cover classification type qualification, thread-local state cleanup, and DNS query suffix handling. ## Experimental API Changes ### New Experimental APIs * New experimental API: HTTP request latency log enrichment (`EXTEXP0013`) #7602 * New experimental API: Chat client routing and failover (`MEAI001`) #7662 ## What's Changed ### AI (`Microsoft.Extensions.AI`, `Microsoft.Extensions.AI.Abstractions`, and `Microsoft.Extensions.AI.OpenAI`) * Add extensible chat client routing #7662 by @joshuajyue (co-authored by @Copilot) * Pass the request's options to the selected client #7685 by @joshuajyue (co-authored by @jozkee @Copilot) * AI.Abstractions: fix ExcludeFromSchema dropped under concurrent AIFunction creation #7677 by @jozkee (co-authored by @Copilot) * Cap OpenAI dependency version ([b10f9c0](dotnet/extensions@b10f9c0)) by @jeffhandley (co-authored by @Copilot) **Note: Microsoft.Extensions.AI.OpenAI constrains its dependency for OpenAI to 2.12.x, preventing OpenAI updates to 2.13.0+ due to an incompatibility. We expect to release Microsoft.Extensions.AI.OpenAI version 10.9.1 during the week of August 17 to address this issue.** ### HTTP Resilience and Diagnostics (`Microsoft.Extensions.Http.Resilience` and `Microsoft.Extensions.Http.Diagnostics`) * Fix Grpc.Net.ClientFactory version range check - Fixes #7565 #7566 by @Ghost93 * Fix response body logging under debugger #7678 by @Rimobul * Redact outgoing path when route is unknown #7687 by @Rimobul * Fix HTTP client logging config binding #7691 by @Rimobul ### ASP.NET Core Extensions (`Microsoft.AspNetCore.Diagnostics.Middleware`) * Rename HttpLatencyTelemetry extensions class and drop redundant TFM guard #7645 by @EasyL0ver (co-authored by @Copilot) * Add HTTP request latency log enricher (experimental) #7602 by @EasyL0ver (co-authored by @Copilot) ### Logging Source Generator (`Microsoft.Gen.Logging`) * [Microsoft.Gen.Logging] Clear thread-local state when logging throws #7682 by @Rimobul * [Microsoft.Gen.Logging] Fully qualify classification types #7689 by @Rimobul ### AI Evaluation (`Microsoft.Extensions.AI.Evaluation.Reporting`) * [Microsoft.Extensions.AI.Evaluation.Reporting] Evaluation report redesign #7609 by @grafanaKibana ### Project Templates (`Microsoft.McpServer.ProjectTemplates`) * Remove MCP server project template #7680 by @jeffhandley (co-authored by @Copilot) ... (truncated) ## 10.8.4 This servicing update refreshes the .NET AI project templates ahead of the July 30, 2026 retirement of GitHub Models — removing the GitHub Models provider option and updating template dependencies. As a result, both the AI Chat Web (`aichatweb`) and AI Agent Web API (`aiagent-webapi`) templates now **require** the AI service provider to be chosen explicitly via `--provider`; there is no longer a default. One of the following must be selected: - `--provider azureopenai` — Azure OpenAI - `--provider ollama` — Ollama (for local development) - `--provider openai` — OpenAI Platform ## Packages in this release | Package | Version | |---|---| | Microsoft.Extensions.AI.Templates | 10.8.4-preview.3.26379.3 | | Microsoft.Agents.AI.ProjectTemplates | 1.13.0-preview.1.26379.3 | ## What's Changed ### Project templates - **Removed the GitHub Models provider** from the AI Chat Web and AI Agent Web API templates, ahead of [GitHub Models being fully retired on July 30, 2026](https://github.blog/changelog/2026-07-01-github-models-is-being-fully-retired-on-july-30-2026/). The `--provider` option is now required with no default ([#7667](dotnet/extensions#7667)). - Updated AI template dependencies — bumped `Aspire.Hosting.AppHost` to `13.4.6` and `CommunityToolkit.VectorData.SqliteVec` to `1.0.0-preview.4` (aligned `System.Linq.AsyncEnumerable` to `10.0.9`), replacing earlier workaround package pins ([#7639](dotnet/extensions#7639)). ## Full Changelog - dotnet/extensions@v10.8.3...v10.8.4 ## 10.8.3 ## Packages in this release | Package | Version | |---|---| | Microsoft.Extensions.AI | 10.8.3 | | Microsoft.Extensions.AI.Abstractions | 10.8.3 | | Microsoft.Extensions.AI.OpenAI | 10.8.3 | ## Experimental API Changes ### Experimental API behavior updates - Updated serialization behavior for experimental `ToolApprovalRequestContent.RequiresConfirmation` so it no longer leaks into consumer source-generated `AIContent` JSON metadata unless approval APIs are intentionally used ([#7659](dotnet/extensions#7659)). ## What's Changed ### AI abstractions and serialization - Fixed MEAI001 leakage from `RequiresConfirmation` in source-generated `AIContent` contexts by using an internal JSON-included backing member while keeping the public experimental member ignored for source-generation metadata ([#7659](dotnet/extensions#7659)). ## Test Improvements - Added stabilization regression coverage to verify consumer source-generated `List<AIContent>` contexts compile and round-trip without requiring MEAI001 suppression ([#7659](dotnet/extensions#7659)). ## Full Changelog - dotnet/extensions@v10.8.2...v10.8.3 ## 10.8.2 This servicing release updates Microsoft.Extensions.VectorData.ConformanceTests to 10.8.2 and includes targeted test framework migration fixes. ## Packages in this release | Package | Version | Note | |---------|---------|---------| | Microsoft.Extensions.VectorData.Abstractions | 10.8.2 | Published August 7, 2026 | | Microsoft.Extensions.VectorData.ConformanceTests | 10.8.2 | | **Update: August 7, 2026** The Microsoft.Extensions.VectorData.Abstractions package was initially excluded from this release by mistake. Because Microsoft.Extensions.VectorData.ConformanceTests has a dependency on Microsoft.Extensions.VectorData.Abstractions, that led to failures when updating to Microsoft.Extensions.VectorData.ConformanceTests 10.8.2. Microsoft.Extensions.VectorData.Abstractions was published August 7, 2026 to resolve that issue. ## What's Changed ### AI * Move Microsoft.Extensions.VectorData.ConformanceTests to xUnit 3 #7636 by @adamsitnik (co-authored by @Copilot) ## Acknowledgements * @roji reviewed pull requests **Full Changelog**: dotnet/extensions@v10.8.1...v10.8.2 ## 10.8.1 This servicing release updates the Microsoft.Extensions.AI, Microsoft.Extensions.AI.Abstractions, and Microsoft.Extensions.AI.OpenAI packages to 10.8.1 with two targeted fixes: correct tool-call/tool-result ordering when resuming approval-gated functions with service-managed chat history, and preservation of the OpenAI Responses reasoning item id for stateless (store=false) encrypted reasoning. ## Packages in this release | Package | Version | |---------|---------| | Microsoft.Extensions.AI | 10.8.1 | | Microsoft.Extensions.AI.Abstractions | 10.8.1 | | Microsoft.Extensions.AI.OpenAI | 10.8.1 | ## What's Changed ### AI * Fix FICC tool_calls/tool ordering with approvals and service-managed chat history #7617 by @westey-m * Roundtrip OpenAI Responses reasoning item id for stateless (store=false) encrypted reasoning #7629 by @rogerbarreto (co-authored by @tarekgh) ## Acknowledgements * @jozkee reviewed pull requests **Full Changelog**: dotnet/extensions@v10.8.0...v10.8.1 Commits viewable in [compare view](dotnet/extensions@v10.8.0...v10.9.0). </details> Updated [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 18.8.1 to 18.9.0. <details> <summary>Release notes</summary> _Sourced from [Microsoft.NET.Test.Sdk's releases](https://github.com/microsoft/vstest/releases)._ ## 18.9.0 ## What's Changed * Fix tilde/exclamation characters corrupted in TerminalLogger test output by @nohwnd in microsoft/vstest#16046 * Make TranslationLayer Native AOT-compatible by @drewnoakes in microsoft/vstest#16045 * Guard GenerateProgramFile target against UseWinUI/UseUwpTools evaluation order by @nohwnd in microsoft/vstest#16072 * Add RequestingAssembly to AssemblyResolveEventArgs for binary compat by @nohwnd in microsoft/vstest#16076 * Remove stale Microsoft.Extensions.FileSystemGlobbing binding redirect from testhost.x86 and datacollector by @Evangelink in microsoft/vstest#16082 * Fix TRX attachment paths when LogFileName contains a subdirectory by @nohwnd in microsoft/vstest#15791 * Fix missing dumps for .NET Framework child processes in NetClientHangDumper by @nohwnd in microsoft/vstest#16098 * Fix data collection channels to use negotiated protocol version instead of V1 by @nohwnd in microsoft/vstest#16096 * Fix race condition in BlameCollector: skip hang dump when testhost hasn't launched yet by @nohwnd in microsoft/vstest#16065 * Replace TestSDKAutoGeneratedCode with ExcludeFromCodeCoverage in auto-generated Program files by @nohwnd in microsoft/vstest#16101 * Include testhost process path in crash error messages by @nohwnd in microsoft/vstest#16108 * Fix DataDriven test results being double-counted in TRX logger totals by @nohwnd in microsoft/vstest#15766 * Fix datacollector crash visibility: replace Assert with throwable exceptions by @nohwnd in microsoft/vstest#16048 * Add TreatErrorMessagesAsWarnings parameter to TRX logger by @nohwnd in microsoft/vstest#16106 * Wait for testhost stderr to drain before reading its crash output by @nohwnd in microsoft/vstest#16128 * Handle runtimeconfig.dev.json without additionalProbingPaths by @tmat in microsoft/vstest#16166 * Suggest Microsoft.NET.Test.Sdk when a managed test project brings no testhost by @nohwnd in microsoft/vstest#16169 * Fix x86 testhost loading mismatched x64 hostfxr (0x800700C1) when run via vstest.console.exe directly (#16151) by @azat-msft in microsoft/vstest#16156 * Preserve the real exception (type + stack trace) when a test run aborts in BaseRunTests by @nohwnd in microsoft/vstest#16167 ## New Contributors * @drewnoakes made their first contribution in microsoft/vstest#16045 **Full Changelog**: microsoft/vstest@v18.8.0...v18.9.0 Commits viewable in [compare view](microsoft/vstest@v18.8.1...v18.9.0). </details> Updated [Microsoft.OpenApi](https://github.com/Microsoft/OpenAPI.NET) from 2.11.0 to 2.12.0. <details> <summary>Release notes</summary> _Sourced from [Microsoft.OpenApi's releases](https://github.com/Microsoft/OpenAPI.NET/releases)._ ## 2.12.0 ## [2.12.0](microsoft/OpenAPI.NET@v2.11.0...v2.12.0) (2026-08-12) ### Features * adds deserialization of the example extension ([095ae3b](microsoft/OpenAPI.NET@095ae3b)) * serialize license identifier as extension for earlier versions ([d5cdce8](microsoft/OpenAPI.NET@d5cdce8)) * serialize license identifier as extension for earlier versions ([fde38d8](microsoft/OpenAPI.NET@fde38d8)) ### Bug Fixes * better nullability round-tripping ([7a25659](microsoft/OpenAPI.NET@7a25659)) * bound YAML anchor/alias expansion to prevent OOM (billion laughs) ([#3000](microsoft/OpenAPI.NET#3000)) ([a361360](microsoft/OpenAPI.NET@a361360)) * bound YAML anchor/alias expansion to prevent OOM (billion laughs) ([#3000](microsoft/OpenAPI.NET#3000)) ([4db9af0](microsoft/OpenAPI.NET@4db9af0)) * **library:** serialize multiple schema types as anyOf/oneOf for OpenAPI 3.0 ([6568896](microsoft/OpenAPI.NET@6568896)) * marks deprecated properties from the specification as obsolete ([26aba69](microsoft/OpenAPI.NET@26aba69)) * marks deprecated properties from the specification as obsolete ([abc5301](microsoft/OpenAPI.NET@abc5301)) * **schema:** serialize compatibility examples from examples list ([be57a7c](microsoft/OpenAPI.NET@be57a7c)) * serialize examples as extension in v2/v3 ([d27141b](microsoft/OpenAPI.NET@d27141b)) Commits viewable in [compare view](microsoft/OpenAPI.NET@v2.11.0...v2.12.0). </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced Aug 18, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The YAML reader is exposed to an uncontrolled-resource-consumption ("billion laughs") denial of service (CWE-400). A tiny YAML document (well under 1 KB) using nested anchors/aliases can force the process to allocate many gigabytes and be OOM-killed. See https://portal.microsofticm.com/imp/v5/incidents/details/31000000667626/summary
Root cause
OpenApiYamlReaderparses YAML via SharpYaml'sYamlStream.Load, which produces a DAG where an alias (*a) resolves to the same sharedYamlNodeinstance — so the parsed graph stays small. The explosion happens inYamlConverter.ToJsonNode, which converts that DAG into aSystem.Text.JsonJsonNodetree. BecauseJsonNodeis single-parent (a node cannot be attached to two parents), every alias occurrence must be materialized as an independent copy. With no bound,Nnested anchors each referencedktimes expand tok^Nnodes → exponential memory → OOM.Deduplication/sharing is not possible (single-parent constraint), so the only viable fix is to bound the work and fail fast.
Fix
Add a conversion budget threaded through
YamlConverter.ToJsonNodethat enforces two limits:Rationale for the values:
System.Text.JsonMaxDepthalready enforced on the JSON reader path (JsonNode.Parse), so this brings YAML to parity — any document deeper than 64 already fails today when supplied as JSON.On breach the budget throws
OpenApiReaderException, whichOpenApiYamlReader.Readconverts into anOpenApiDiagnosticerror (Document = null) — consistent with the existingJsonExceptionhandling — instead of allowing an OOM.Configurable limits
The two limits are exposed as public static
uintproperties onYamlConverterso consumers are never blocked by the defaults:YamlConverter.MaxDepth(defaultYamlConverter.DefaultMaxDepth= 64)YamlConverter.MaxNodeCount(defaultYamlConverter.DefaultMaxNodeCount= 5,000,000)A consumer that must ingest an unusually large/deep-but-trusted document can raise the limits; a consumer that only ever parses small documents can lower them to fail faster.
uintmakes the non-negative intent explicit at the type level (negative literals fail to compile), and the setters reject0. These are the only additions to the public API (recorded inPublicAPI.Unshipped.txt).Note the limits are process-wide static state, best configured once at startup. They are an escape hatch for the defaults, not per-parse/per-thread configuration.
Tests
YamlConverterTests.ExponentialAliasExpansionIsRejected— a nested anchor/alias bomb is rejected instead of exhausting memory.YamlConverterTests.ExcessiveNestingDepthIsRejected— nesting beyond the depth limit is rejected.YamlConverterTests.LegitimateAliasesStillConvert— normal alias usage still converts correctly.YamlConverterTests.ConversionLimitsDefaultToDocumentedValues— the properties expose the documented defaults.YamlConverterTests.SettingMaxDepthToZeroThrows/SettingMaxNodeCountToZeroThrows— zero limits are rejected and leave the effective limit unchanged.YamlConverterTests.RaisingMaxDepthAllowsDocumentsDeeperThanTheDefault— raising the limit permits a document deeper than the default.OpenApiYamlReaderTests.ReadReturnsDiagnosticErrorForExponentialAliasExpansion— the reader surfaces a diagnostic error (no document), not a throw/OOM.Full
Microsoft.OpenApi.Readers.Testssuite passes.Validation on a large real-world spec (no false positives)
To confirm the limits do not reject legitimately large production descriptions, the Microsoft Graph beta OpenAPI document was loaded end-to-end through the patched reader.
microsoftgraph/msgraph-metadata@73fc270c924975a98f8f9d93d61fd4cff2297084, pathopenapi/beta/openapi.yaml830108DDB021845583F0C9F6D185BCE465CA4CB1E673E50B2F98DB05E54C21ADResult under the patched build (with default limits):
OpenApiDocument.LoadAsyncThe largest realistic production spec sits well below both caps, while the exponential bomb (theoretical ~387M nodes) is rejected almost immediately. The limits target the exponential pathology, not document size.
Notes / scope
$refstack overflow), which was already fixed in 3.5.4.ReadFragmentis still protected by the budget (it throws rather than OOM) but does not convert the exception to a diagnostic — left out of scope intentionally; happy to extend if preferred.support/v2; a companion PR will follow.support/v1uses a different YAML parsing path and needs a separate assessment.