Repository navigation
Apply a number of mitigations to System.Security.Cryptography.Xml - #130705
Merged
Merged
Conversation
eiriktsarpalis
temporarily deployed
to
copilot-pat-pool
July 14, 2026 18:10 — with
GitHub Actions
Inactive
eiriktsarpalis
temporarily deployed
to
copilot-pat-pool
July 14, 2026 18:10 — with
GitHub Actions
Inactive
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
eiriktsarpalis
had a problem deploying
to
copilot-pat-pool
July 14, 2026 18:12 — with
GitHub Actions
Failure
eiriktsarpalis
temporarily deployed
to
copilot-pat-pool
July 14, 2026 18:13 — with
GitHub Actions
Inactive
eiriktsarpalis
temporarily deployed
to
copilot-pat-pool
July 14, 2026 18:13 — with
GitHub Actions
Inactive
eiriktsarpalis
temporarily deployed
to
copilot-pat-pool
July 14, 2026 18:14 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Pull request overview
This PR applies several robustness/security mitigations to System.Security.Cryptography.Xml, primarily by bounding attacker-controlled XML workloads (transform chain length, encrypted element processing) and reducing memory retention during transform processing.
Changes:
- Add AppContext-configurable limits for (1) number of transforms in a deserialized
TransformChainand (2) number ofEncryptedDataelements processed byXmlDecryptionTransform. - Introduce
Transform.ClearState()and invoke it during transform-chain execution, with overrides in key built-in transforms to release intermediate state. - Add new regression/behavior tests (including an embedded XML resource) covering transform reuse, transform-chain limits, and encrypted element limits.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Security.Cryptography.Xml/tests/TransformChainTest.cs | Adds a test ensuring the same transform instance can be applied twice in a chain. |
| src/libraries/System.Security.Cryptography.Xml/tests/System.Security.Cryptography.Xml.Tests.csproj | Embeds a new encrypted XML sample resource used by new tests. |
| src/libraries/System.Security.Cryptography.Xml/tests/SignedXml_SignatureMethodAlgorithm.cs | Adds tests for large transform algorithm strings and encrypted-element processing limits (including AppContext switch behavior). |
| src/libraries/System.Security.Cryptography.Xml/tests/EncryptedXmlTests.cs | Adds tests validating transform-chain length limits and behavior when the limit is adjusted/disabled. |
| src/libraries/System.Security.Cryptography.Xml/tests/EncryptedXmlSample5.xml | New crafted encrypted XML payload exercising long transform chains / encoded DTD scenarios. |
| src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlLicenseTransform.cs | Implements ClearState() to drop cached document/namespace state. |
| src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigXsltTransform.cs | Implements ClearState() to release input stream reference after output is produced. |
| src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigXPathTransform.cs | Implements ClearState() to release the cached input document. |
| src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigExcC14NTransform.cs | Implements ClearState() to release canonicalization state. |
| src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigEnvelopedSignatureTransform.cs | Implements ClearState() to release document/nodelist/ns-manager state. |
| src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigC14NTransform.cs | Implements ClearState() to release canonicalization state. |
| src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDsigBase64Transform.cs | Implements ClearState() to release the transform’s CryptoStream reference. |
| src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/XmlDecryptionTransform.cs | Adds a configurable cap on processed EncryptedData elements and implements ClearState(). |
| src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/TransformChain.cs | Enforces transform-chain length limit on deserialization and clears per-transform state after output generation. |
| src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/Transform.cs | Introduces the internal virtual ClearState() hook for transforms. |
| src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/LocalAppContextSwitches.cs | Adds AppContext switches and defaults for the new limits. |
| src/libraries/System.Security.Cryptography.Xml/src/System/Security/Cryptography/Xml/CryptoHelpers.cs | Extends invalid character filtering to block nested-type (+) usage in algorithm names. |
| src/libraries/System.Security.Cryptography.Xml/src/Resources/Strings.resx | Adds a localized error string for exceeding the decrypted-element processing cap. |
bartonjs
reviewed
Jul 14, 2026
bartonjs
reviewed
Jul 14, 2026
tannergooding
approved these changes
Jul 14, 2026
Member
|
Its already "in", so LGTM. But a couple pieces of feedback |
eiriktsarpalis
temporarily deployed
to
copilot-pat-pool
July 15, 2026 06:44 — with
GitHub Actions
Inactive
eiriktsarpalis
temporarily deployed
to
copilot-pat-pool
July 15, 2026 06:44 — with
GitHub Actions
Inactive
eiriktsarpalis
had a problem deploying
to
copilot-pat-pool
July 15, 2026 06:45 — with
GitHub Actions
Failure
eiriktsarpalis
temporarily deployed
to
copilot-pat-pool
July 15, 2026 06:46 — with
GitHub Actions
Inactive
eiriktsarpalis
temporarily deployed
to
copilot-pat-pool
July 15, 2026 06:47 — with
GitHub Actions
Inactive
eiriktsarpalis
temporarily deployed
to
copilot-pat-pool
July 15, 2026 06:47 — with
GitHub Actions
Inactive
eiriktsarpalis
force-pushed
the
xml-fixes-7b
branch
from
July 15, 2026 07:02
bb18e56 to
fe51b37
Compare
eiriktsarpalis
temporarily deployed
to
copilot-pat-pool
July 15, 2026 09:47 — with
GitHub Actions
Inactive
eiriktsarpalis
had a problem deploying
to
copilot-pat-pool
July 15, 2026 09:48 — with
GitHub Actions
Failure
eiriktsarpalis
temporarily deployed
to
copilot-pat-pool
July 15, 2026 09:49 — with
GitHub Actions
Inactive
eiriktsarpalis
temporarily deployed
to
copilot-pat-pool
July 15, 2026 09:49 — with
GitHub Actions
Inactive
eiriktsarpalis
temporarily deployed
to
copilot-pat-pool
July 15, 2026 09:50 — with
GitHub Actions
Inactive
tannergooding
approved these changes
Jul 15, 2026
Co-authored-by: Copilot <[email protected]> Copilot-Session: 1e296050-3562-4cbc-8cf7-91541c1f87eb
eiriktsarpalis
temporarily deployed
to
copilot-pat-pool
July 15, 2026 13:21 — with
GitHub Actions
Inactive
eiriktsarpalis
temporarily deployed
to
copilot-pat-pool
July 15, 2026 13:21 — with
GitHub Actions
Inactive
eiriktsarpalis
had a problem deploying
to
copilot-pat-pool
July 15, 2026 13:23 — with
GitHub Actions
Failure
eiriktsarpalis
temporarily deployed
to
copilot-pat-pool
July 15, 2026 13:24 — with
GitHub Actions
Inactive
eiriktsarpalis
temporarily deployed
to
copilot-pat-pool
July 15, 2026 13:24 — with
GitHub Actions
Inactive
eiriktsarpalis
temporarily deployed
to
copilot-pat-pool
July 15, 2026 13:24 — with
GitHub Actions
Inactive
Member
Author
|
/ba-g test failure is unrelated |
tannergooding
approved these changes
Jul 15, 2026
This branch was previously deployed
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
No description provided.