Skip to content

Conversation

@vcsjones
Copy link
Member

@vcsjones vcsjones commented Jan 2, 2026

CRLBuilder.LoadPem asserted that the DER data read is the same amount as the decoded length of the data, however the DER reader does not enforce no trailing data, so this assert could be reached.

This change blocks trailing data in the PEM, and changes the assert to an actual exception.

Fixes #122823

…Pem.

CRLBuilder.LoadPem asserted that the DER data read is the same amount as the decoded length of the data, however the DER reader does not enforce no trailing data, so this assert could be reached.

This change blocks trailing data in the PEM, and changes the assert to an actual exception.
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

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 fixes a security vulnerability in CertificateRevocationListBuilder.LoadPem where trailing data in PEM-encoded CRLs was not properly validated. The fix converts a Debug.Assert into a proper exception and adds test coverage for the scenario.

  • Replaces Debug.Assert with proper validation that throws CryptographicException when trailing data is detected
  • Adds comprehensive test coverage for both string and ReadOnlySpan overloads of LoadPem with trailing data

Reviewed changes

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

File Description
CertificateRevocationListBuilder.Load.cs Replaces Debug.Assert with proper exception throwing when bytesConsumed != bytesWritten
CrlBuilderTests.cs Adds new test case LoadPem_TrailingData to verify trailing data is properly rejected

@stephentoub
Copy link
Member

/ba-g deadletter

@stephentoub stephentoub merged commit b57b9c9 into dotnet:main Jan 3, 2026
83 of 85 checks passed
@vcsjones vcsjones deleted the fix-122823 branch January 3, 2026 17:06
@vcsjones vcsjones added this to the 11.0.0 milestone Jan 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reachable assert in CertificateRevocationListBuilder.LoadPem with trailing data

3 participants