Repository navigation
Bound Blazor client validation caching - #70453
Conversation
Co-authored-by: Copilot <[email protected]> Copilot-Session: fdac132c-0926-4fda-8c97-88ae5b59b9fd
There was a problem hiding this comment.
🟢 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
|
/review |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Approving. The new IL2080 reflects the same trimming assumption as the existing lookup and can be addressed as a follow-up.
|
ℹ️ 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. |
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.