Skip to content

Bound Blazor client validation caching - #70453

Merged
rbhanda merged 4 commits into
mainfrom
security/cve-2026-118748-main
Nov 11, 2026
Merged

rbhanda merged 4 commits into
mainfrom
security/cve-2026-118748-main

Conversation

@rbhanda

@rbhanda rbhanda commented Nov 10, 2026

Copy link
Copy Markdown
Contributor
  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making.

Description

Avoid retaining attacker-controlled rendered field names in the singleton Blazor client-validation cache. Unknown field names are not cached, and model-validation reachability is evaluated per request.

This addresses CVE-2026-118748.

Validation

A focused regression verifies that unknown field names do not grow the metadata cache. The managed test could not complete locally because repository-generated build prerequisites were unavailable after restore; normal PR CI is required before merge.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: fdac132c-0926-4fda-8c97-88ae5b59b9fd
@github-actions github-actions Bot added the area-blazor Includes: Blazor, Razor Components label Nov 10, 2026
@rbhanda
rbhanda requested a review from oroztocil November 10, 2026 18:42
@rbhanda
rbhanda marked this pull request as ready for review November 10, 2026 22:32
@rbhanda
rbhanda requested a review from a team as a code owner November 10, 2026 22:32
Copilot AI balanced review requested due to automatic review settings November 10, 2026 22:32
@rbhanda
rbhanda enabled auto-merge November 10, 2026 22:32

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.

🟢 Approval recommended

No active review issues were identified, though CI validation is still needed because missing generated prerequisites prevented local regression-test verification.

No open issues 🎉

What changed in this PR

This PR limits retained data in Blazor’s singleton client-validation cache while preserving server-validation eligibility checks.

Changes:

  • Avoid caching metadata for field names that do not match public instance properties.
  • Remove the cross-request field-reachability cache and evaluate reachability per request.
  • Add a regression test asserting that unknown field names leave the metadata cache empty.

The managed regression test remains unverified locally because generated build prerequisites were unavailable; CI validation is still needed.

File Description
src/​Components/​Endpoints/​test/​FormValidation/​ClientValidationProviderTests.cs Adds coverage for unknown field names not entering the metadata cache.
src/​Components/​Endpoints/​src/​Forms/​ClientValidationCache.cs Filters unknown names before caching and removes cached field reachability.

Review effort: Balanced

@PureWeen

Copy link
Copy Markdown
Member

/review

@github-actions github-actions Bot 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.

Source-only review of frozen head 27a9b899bb4ef364b9f96db17ec01758933b83a4.

One changed-line candidate is published inline as unresolved, not as a verified defect: the new unsuppressed Type.GetProperty call may produce IL2070 during trimming analysis, but the frozen bundle does not contain target-linker source, a binding linker contract, or immutable publish output proving the diagnostic.

Both routed guides completed independently with gpt-5.6-sol: docs/CrossCuttingGuidance.md and docs/BlazorComponentsGuidance.md. They converged on this candidate; the independent verifier confirmed the changed call and old/new suppression difference, then downgraded the effect for missing external evidence.

Existing feedback: The prepared feedback contains no equivalent reported issue; its prior review reported no open issues. Deduplication is neutral and does not endorse that review. Feedback posted after bundle preparation is not observable.

Coverage: No materially changed area was left without a routed guide. Runtime execution, builds, tests, trimming publishes, CI, browser workflows, samples, and security implications were excluded by the supplied policies. The added unit test was assessed from source and would fail against the old null-entry caching behavior.

Provenance and limits: Evidence is limited to tracked bytes frozen at head 27a9b899bb4ef364b9f96db17ec01758933b83a4, merge base f9e9de7963338db168cf2a2d95ab6b1568d8ee1b, base tip/guidance commit 8e7e17d8c477eb96127088eca20cbaf0fa7afdb3, and prepared feedback. Symlinks, submodules, and LFS targets are inert; no target code was executed.

Generated by ASP.NET Core Pull Request Review for #70453 · copilot · gpt56 · 152.1 AIC · ⌖ 12.5 AIC · ⊞ 18.8K
Comment /review to run again

if (!_metadataCache.TryGetValue(fieldKey, out var cachedMetadata))
{
// Don't cache unknown names, which can be arbitrary dictionary keys.
if (fieldKey.ContainerType.GetProperty(fieldKey.FieldName, BindingFlags.Public | BindingFlags.Instance) is null)

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.

[P2, unresolved] [UNRESOLVED] Could this new reflection check emit IL2070 during a trimmed publish?

The old path reached GetProperty only inside BuildFieldMetadata, where IL2070 is explicitly suppressed, while this new cache-miss precheck calls the same API without that suppression.

Why unresolved: The frozen evidence does not include a target-version linker contract, linker source, or immutable publish artifact proving that this assembly/method is analyzed and that this call emits IL2070.

Minimal repro: In a trimmed publish that analyzes ClientValidationCache.GetValidatableFieldMetadata, enumerate it with empty ValidationOptions, a Dictionary<string, string> model, and an uncached field named attacker-key-0.

What may go wrong: Trimming analysis may introduce a new warning in shipping framework code.

Possible fix: Move the existence check into a narrowly scoped helper carrying the same justified IL2070 suppression as BuildFieldMetadata.

@halter73 halter73 Nov 11, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks like a good catch. The NativeAOT publish log reports IL2080 here. This looks like the same trimming assumption BuildFieldMetadata already makes. Could it report whether the property exists so we can avoid the extra reflection call and only cache known properties?

@halter73 halter73 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approving. The new IL2080 reflects the same trimming assumption as the existing lookup and can be addressed as a follow-up.

@rbhanda
rbhanda merged commit 8649774 into main Nov 11, 2026
25 of 31 checks passed
@rbhanda
rbhanda deleted the security/cve-2026-118748-main branch November 11, 2026 00:54
@rbhanda
rbhanda temporarily deployed to copilot-pat-pool November 11, 2026 00:54 — with GitHub Actions Inactive
@rbhanda
rbhanda temporarily deployed to copilot-pat-pool November 11, 2026 00:54 — with GitHub Actions Inactive
@rbhanda
rbhanda temporarily deployed to copilot-pat-pool November 11, 2026 00:55 — with GitHub Actions Inactive
@rbhanda
rbhanda temporarily deployed to copilot-pat-pool November 11, 2026 00:56 — with GitHub Actions Inactive
@rbhanda
rbhanda temporarily deployed to copilot-pat-pool November 11, 2026 00:58 — with GitHub Actions Inactive
@rbhanda
rbhanda temporarily deployed to copilot-pat-pool November 11, 2026 00:58 — with GitHub Actions Inactive
@github-actions

Copy link
Copy Markdown
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.

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — 27a9b899 Deployed Nov 11, 2026 by rbhanda via conclusion #285
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants