-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix trailing data handling with CertificateRevocationListBuilder.LoadPem. #122825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…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.
|
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones |
...y/src/System/Security/Cryptography/X509Certificates/CertificateRevocationListBuilder.Load.cs
Show resolved
Hide resolved
There was a problem hiding this 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.Assertwith proper validation that throwsCryptographicExceptionwhen 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 |
|
/ba-g deadletter |
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