Repository navigation
[main] Avoid repeated validation error copies (CVE-2026-118749) - #70449
Merged
Merged
Conversation
Co-authored-by: Copilot <[email protected]> Copilot-Session: fdac132c-0926-4fda-8c97-88ae5b59b9fd
Youssef1313
approved these changes
Nov 10, 2026
rbhanda
marked this pull request as ready for review
November 10, 2026 22:25
rbhanda
enabled auto-merge
November 10, 2026 22:30
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Exposing the backing dictionary and mutable value lists lets callers alter collected errors and replace lists with arrays, causing later AddValidationError calls to fail at the list cast.
1 open issue
What changed in this PR
This PR reduces repeated allocations when accessing collected validation errors in Microsoft.Extensions.Validation, while keeping the public property signature unchanged.
Changes:
- Returns the existing error dictionary instead of rebuilding it on each access.
- Adjusts internal storage and appending to use read-only list interfaces.
- Adds repeated-access identity coverage for synchronous and asynchronous validation, and removes the immutability test.
| File | Description |
|---|---|
| src/Validation/test/Microsoft.Extensions.Validation.Tests/ValidatableParameterInfoTests.cs | Adds no-copy coverage and removes collection immutability assertions. |
| src/Validation/src/ValidateContext.cs | Returns backing error storage directly and adjusts per-path error insertion. |
Review effort: Balanced
| /// </remarks> | ||
| public IReadOnlyDictionary<string, IReadOnlyList<ValidationError>>? ValidationErrors | ||
| => _validationErrors?.ToDictionary(kvp => kvp.Key, kvp => (IReadOnlyList<ValidationError>)kvp.Value.AsReadOnly()).AsReadOnly(); | ||
| => _validationErrors; |
Youssef1313
approved these changes
Nov 10, 2026
wtgodbe
approved these changes
Nov 11, 2026
rbhanda
temporarily deployed
to
copilot-pat-pool
November 11, 2026 00:57 — with
GitHub Actions
Inactive
rbhanda
temporarily deployed
to
copilot-pat-pool
November 11, 2026 00:57 — with
GitHub Actions
Inactive
rbhanda
temporarily deployed
to
copilot-pat-pool
November 11, 2026 00:58 — with
GitHub Actions
Inactive
rbhanda
temporarily deployed
to
copilot-pat-pool
November 11, 2026 00:59 — with
GitHub Actions
Inactive
rbhanda
temporarily deployed
to
copilot-pat-pool
November 11, 2026 01:01 — with
GitHub Actions
Inactive
rbhanda
temporarily deployed
to
copilot-pat-pool
November 11, 2026 01:01 — with
GitHub Actions
Inactive
Contributor
|
ℹ️ This pull request wasn't processed automatically. This change requires specialized review. Please confirm whether documentation updates are needed and handle them through the appropriate process. |
rbhanda
temporarily deployed
to
copilot-pat-pool
November 11, 2026 01:01 — with
GitHub Actions
Inactive
This branch was previously deployed
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.

Summary
Addresses CVE-2026-118749.
Testing
Not run locally. The focused repository test setup was blocked before compilation because the required .NET 12 SDK needs MSBuild 18.7 or newer, while this machine has MSBuild 17.15. CI validation is required.