Repository navigation
[MarkupStringSanitized] Prevent regex timeouts in markup sanitization - #5429
Merged
Denis Voituron (dvoituron) merged 4 commits intoOct 11, 2026
Merged
Conversation
…ance and remove timeout settings
…regex performance
Denis Voituron (dvoituron)
requested a review
from Vincent Baaij (vnbaaij)
as a code owner
October 11, 2026 12:44
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The revised expressions preserve covered behavior while removing timeout-based failure modes.
0 open findings
What changed in this PR
Reworks markup sanitization regexes to use deterministic non-backtracking execution, preventing timeout exceptions and regex denial-of-service risks.
Changes:
- Splits inline-style validation from unsafe-content detection.
- Replaces backreferences with explicit quote captures and closing-tag handling.
- Removes regex timeouts in favor of
RegexOptions.NonBacktracking.
| File | Description |
|---|---|
src/Core/Utilities/MarkupStringSanitized.cs |
Converts sanitization and parsing regexes to non-backtracking implementations. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
✅ All tests passed successfully Details on your Workflow / Core Tests page. |
Summary - Unit Tests Code CoverageSummary
CoverageMicrosoft.FluentUI.AspNetCore.Components - 98.2%
Microsoft.FluentUI.AspNetCore.Components.Charts - 100%
|
Vincent Baaij (vnbaaij)
approved these changes
Oct 11, 2026
Denis Voituron (dvoituron)
deleted the
users/dvoituron/fix-regex-timeout
branch
October 11, 2026 12:56
This was referenced Oct 14, 2026
Closed
Closed
Merged
This was referenced Oct 19, 2026
Closed
Closed
This was referenced Oct 28, 2026
Merged
Closed
This was referenced Nov 9, 2026
This was referenced Nov 19, 2026
Merged
Closed
This was referenced Nov 27, 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.
[MarkupStringSanitized] Prevent regex timeouts in markup sanitization
Replace the timeout-based regular expressions used by
MarkupStringSanitizedwith expressions usingRegexOptions.NonBacktracking.The inline-style sanitizer was split into an allowed-character validation and a separate unsafe-content check. Regex backreferences used by the markup parser were replaced with explicit quote groups and deterministic closing-tag handling.
Benefits:
RegexMatchTimeoutExceptionfrom interrupting Blazor Server circuits during GC pauses or temporary CPU starvation.MA0009analyzer warning.This is a non-breaking internal implementation change.
This fix the issue #5428
Unit Tests