Harden Visio comments loading to prevent XML DoS#1927
Merged
PrzemyslawKlys merged 2 commits intoJun 16, 2026
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48e94a2623
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1927 +/- ##
==========================================
+ Coverage 72.30% 73.33% +1.03%
==========================================
Files 1956 2521 +565
Lines 225358 283242 +57884
Branches 48654 60594 +11940
==========================================
+ Hits 162943 207716 +44773
- Misses 40161 47886 +7725
- Partials 22254 27640 +5386 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Motivation
visio/comments.xmlpart viaXDocument.Loadwhich could exhaust memory/CPU when fed attacker-controlled large or highly compressed XML.Description
MaxCommentsPartBytes,MaxCommentsXmlCharacters,MaxLoadedComments, andMaxCommentTextCharactersand a hardenedXmlReaderSettingsused for comments parsing.XDocument.Load(stream)withLoadCommentsXmlwhich reads through aBoundedReadStreamand anXmlReaderconfigured with the secure settings to enforce decompressed-byte and XML-character caps.CommentEntryelements and validate per-comment text length before constructingVisioCommentobjects, throwingInvalidDataExceptionwhen limits are exceeded.OfficeIMO.Tests/Visio.Comments.csthat exercise oversized comments XML, excessive comment entries, and oversized comment text, plus helpers that replace thevisio/comments.xmlpart in a generated VSDX for the tests.Testing
PATH=/tmp/dotnet:$PATH dotnet build OfficeIMO.Visio/OfficeIMO.Visio.csproj -f net8.0and the project built successfully.PATH=/tmp/dotnet:$PATH dotnet build OfficeIMO.Visio/OfficeIMO.Visio.csproj -f net10.0 --no-restoreand-f netstandard2.0 --no-restoreand both builds succeeded.PATH=/tmp/dotnet:$PATH dotnet test OfficeIMO.Tests/OfficeIMO.Tests.csproj -f net8.0 --filter FullyQualifiedName~VisioCommentTestsand the filtered tests passed (Passed: 7).dotnet buildof the test project fornet10.0and it completed with no errors (warnings only).Codex Task