Title: New X509Certificate2 crashes PowerShell with AccessViolationException when certain properties are referenced · Issue #7806 · PowerShell/PowerShell · GitHub
Open Graph Title: New X509Certificate2 crashes PowerShell with AccessViolationException when certain properties are referenced · Issue #7806 · PowerShell/PowerShell
X Title: New X509Certificate2 crashes PowerShell with AccessViolationException when certain properties are referenced · Issue #7806 · PowerShell/PowerShell
Description: Issue from Bryant (@keystroke). When a new X509Certificate2 object is created with the empty constructor, it succeeds. However, it is initialised with its Handle property set to IntPtr.Zero. So accessing certain properties on that object...
Open Graph Description: Issue from Bryant (@keystroke). When a new X509Certificate2 object is created with the empty constructor, it succeeds. However, it is initialised with its Handle property set to IntPtr.Zero. So acc...
X Description: Issue from Bryant (@keystroke). When a new X509Certificate2 object is created with the empty constructor, it succeeds. However, it is initialised with its Handle property set to IntPtr.Zero. So acc...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/7806
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"New X509Certificate2 crashes PowerShell with AccessViolationException when certain properties are referenced","articleBody":"Issue from @keystroke.\r\n\r\nWhen a new X509Certificate2 object is created with the empty constructor, it succeeds. However, it is initialised with its `Handle` property set to `IntPtr.Zero`. So accessing certain properties on that object try to dereference that `Handle` and cause an access violation.\r\n\r\nSteps to reproduce\r\n------------------\r\n\r\n```powershell\r\n$cert = [System.Security.Cryptography.X509Certificates.X509Certificate2]::new(); $cert.SendAsTrustedIssue\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\n\r\nValue is possibly `$null` or `False`.\r\n\r\nActual behavior\r\n---------------\r\n\r\nPowerShell crashes (the window disappears)\r\n\r\nFurther Information\r\n-----------------------\r\n\r\nAlso try\r\n```powershell\r\n[System.Security.Cryptography.X509Certificates.X509Certificate2]::new() | fl *\r\n```\r\n\r\nThis crash reproduces back to Windows PowerShell 5.1.\r\n\r\nThe property accessed in the particular repro is a script property that triggers this method:\r\nhttps://github.com/PowerShell/PowerShell/blob/8d4dd1e58f025ca576d38846b9adb5bdeeafd505/src/Microsoft.PowerShell.Security/security/CertificateProvider.cs#L2958-L2988\r\n\r\nIt seems that `X509Certificate2` has a property called `Handle` which is set to `IntPtr.Zero` by default, causing the access violation.\r\n\r\nEnvironment data\r\n----------------\r\n\r\n\u003c!-- provide the output of $PSVersionTable -->\r\n\r\n```powershell\r\n> $PSVersionTable\r\n\r\nName Value\r\n---- -----\r\nPSVersion 6.1.0\r\nPSEdition Core\r\nGitCommitId 6.1.0\r\nOS Microsoft Windows 10.0.18242\r\nPlatform Win32NT\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n```\r\n","author":{"url":"https://github.com/rjmholt","@type":"Person","name":"rjmholt"},"datePublished":"2018-09-17T23:22:17Z","url":"https://github.com/PowerShell/PowerShell/issues/7806"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6f9ef926-0d57-5b56-d2df-d33a55f7affb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9622:2C529F:5C4166:840FD6:6AFD8B05 |
| html-safe-nonce | 09af5bfb02312893e71f4c22d9273b1c829d0ef823f199c6d6b2656cee9a6df6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NjIyOjJDNTI5Rjo1QzQxNjY6ODQwRkQ2OjZBRkQ4QjA1IiwidmlzaXRvcl9pZCI6IjExMTU0NzAwNjU4OTA1OTM1NDEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6c2f5b9178a62d74d65767fb55639e78e41166e21e514ac84cb843349eaf22bf |
| hovercard-subject-tag | issue:361079865 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/7806/issue_layout |
| twitter:image | https://opengraph.githubassets.com/27a3be455075d603f6b1d3a7f1cfd2e9379cd98bb921a404656c2be6afd00090/PowerShell/PowerShell/issues/7806 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/27a3be455075d603f6b1d3a7f1cfd2e9379cd98bb921a404656c2be6afd00090/PowerShell/PowerShell/issues/7806 |
| og:image:alt | Issue from Bryant (@keystroke). When a new X509Certificate2 object is created with the empty constructor, it succeeds. However, it is initialised with its Handle property set to IntPtr.Zero. So acc... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rjmholt |
| hostname | github.com |
| expected-hostname | github.com |
| None | bc86424ef34a73b386237872800e922d149d65ba907f63d6f150a2dcb8433bea |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 927a6c5ab1c32b38830f1b9d3050c0b9e9aa92e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width