Skip to content

Prevent xml DoS attacks#6419

Merged
premun merged 3 commits into
mainfrom
dkurepa/ImproveXmlParsing
Jun 22, 2026
Merged

Prevent xml DoS attacks#6419
premun merged 3 commits into
mainfrom
dkurepa/ImproveXmlParsing

Conversation

@dkurepa

@dkurepa dkurepa commented Jun 22, 2026

Copy link
Copy Markdown
Member

Copilot AI review requested due to automatic review settings June 22, 2026 06:57

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.

Pull request overview

This PR hardens DARC’s XML parsing for dependency/version files against DTD-based entity expansion attacks (e.g., “billion laughs”) by prohibiting DTD processing and disabling XML resolvers, with a regression test to validate the behavior.

Changes:

  • Updated XML-loading helpers to use XmlReader with secure XmlReaderSettings (DtdProcessing = Prohibit, XmlResolver = null) instead of XmlDocument.LoadXml.
  • Applied the same protection in both DependencyFileManager and VersionDetailsParser XML parsing paths.
  • Added a unit test to ensure DTD/entity-expansion payloads are rejected.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
test/Darc/Microsoft.DotNet.DarcLib.Tests/Helpers/DependencyFileManagerTests.cs Adds coverage verifying DTD/entity-expansion XML is rejected.
src/Microsoft.DotNet.Darc/DarcLib/Helpers/VersionDetailsParser.cs Switches XML loading to a secure XmlReader configuration to prohibit DTDs.
src/Microsoft.DotNet.Darc/DarcLib/Helpers/DependencyFileManager.cs Switches XML loading to a secure XmlReader configuration to prohibit DTDs.

@dkurepa dkurepa enabled auto-merge (squash) June 22, 2026 08:42
@premun premun disabled auto-merge June 22, 2026 09:22
@premun premun enabled auto-merge (squash) June 22, 2026 09:23
Copilot AI review requested due to automatic review settings June 22, 2026 09:26

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment on lines +1199 to +1203
var readerSettings = new XmlReaderSettings
{
DtdProcessing = DtdProcessing.Prohibit,
XmlResolver = null
};
Comment on lines +201 to +205
var readerSettings = new XmlReaderSettings
{
DtdProcessing = DtdProcessing.Prohibit,
XmlResolver = null
};
Comment on lines +207 to +208
using var reader = XmlReader.Create(new StringReader(fileContent), readerSettings);
document.Load(reader);
@premun premun merged commit b05fee0 into main Jun 22, 2026
8 of 12 checks passed
@premun premun deleted the dkurepa/ImproveXmlParsing branch June 22, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants