Skip to content
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

Change X509Certificate2 constructor to fix KB5025823 #1343

Merged
merged 1 commit into from
Jul 19, 2023

Conversation

weng5e
Copy link
Contributor

@weng5e weng5e commented Jul 19, 2023

Change X509Certificate2 constructor to fix KB5025823. The framework is adding some extra heuristic check for certificate raw data. This issue might only happen for about 1% of certificates (very rough number).

From the KB:
This additional validation performs a series of heuristic checks to determine if the incoming certificate would maliciously exhaust resourcese upon import. Since this is additional validation beyond what the underlying OS would normally perform, it may block certificate blobs which would have successfully imported prior to the June 13, 2023, change.

Example exception

---> System.Security.Cryptography.CryptographicException: PKCS12 (PFX) without a supplied password has exceeded maximum allowed iterations. See https://go.microsoft.com/fwlink/?linkid=2233907 for more information.
---> System.Formats.Asn1.AsnContentException: The encoded length exceeds the maximum supported by this library (Int32.MaxValue).
at System.Formats.Asn1.AsnDecoder.ReadSequence(ReadOnlySpan1 source, AsnEncodingRules ruleSet, Int32& contentOffset, Int32& contentLength, Int32& bytesConsumed, Nullable1 expectedTag)
at System.Security.Cryptography.Asn1.Pkcs12.PfxAsn.CountTotalIterations()
at System.Security.Cryptography.X509Certificates.X509Certificate.GetIterationCount(ReadOnlySpan1 pkcs12) at System.Security.Cryptography.X509Certificates.X509Certificate.EnforceIterationCountLimit(ReadOnlySpan1 pkcs12, Boolean readingFromFile, Boolean passwordProvided)
--- End of inner exception stack trace ---
at System.Security.Cryptography.X509Certificates.X509Certificate.EnforceIterationCountLimit(ReadOnlySpan1 pkcs12, Boolean readingFromFile, Boolean passwordProvided) at Internal.Cryptography.Pal.PkcsFormatReader.TryReadPkcs12(ReadOnlySpan1 rawData, OpenSslPkcs12Reader pfx, SafePasswordHandle password, Boolean single, Boolean ephemeralSpecified, Boolean readingFromFile, ICertificatePal& readPal, List1& readCerts) at Internal.Cryptography.Pal.PkcsFormatReader.TryReadPkcs12(ReadOnlySpan1 rawData, SafePasswordHandle password, Boolean single, Boolean ephemeralSpecified, Boolean readingFromFile, ICertificatePal& readPal, List1& readCerts, Exception& openSslException) at Internal.Cryptography.Pal.OpenSslX509CertificateReader.FromBlob(ReadOnlySpan1 rawData, SafePasswordHandle password, X509KeyStorageFlags keyStorageFlags)
at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(ReadOnlySpan`1 data)

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jul 19, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: weng5e / name: wuweng (9ad1946)

@k8s-ci-robot
Copy link
Contributor

Welcome @weng5e!

It looks like this is your first PR to kubernetes-client/csharp 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-client/csharp has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jul 19, 2023
@tg123 tg123 enabled auto-merge July 19, 2023 17:27
@tg123 tg123 disabled auto-merge July 19, 2023 17:27
@codecov-commenter
Copy link

codecov-commenter commented Jul 19, 2023

Codecov Report

❗ No coverage uploaded for pull request base (master@dfa5cc9). Click here to learn what that means.
The diff coverage is n/a.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff            @@
##             master    #1343   +/-   ##
=========================================
  Coverage          ?   70.60%           
=========================================
  Files             ?       89           
  Lines             ?     2677           
  Branches          ?        0           
=========================================
  Hits              ?     1890           
  Misses            ?      787           
  Partials          ?        0           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jul 19, 2023
Copy link
Member

@tg123 tg123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/LGTM

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 19, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tg123, weng5e

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 19, 2023
@k8s-ci-robot k8s-ci-robot merged commit 3edf256 into kubernetes-client:master Jul 19, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants