ghsa-h34r-jxqm-qgpr
Vulnerability from github
Summary
Certs generated by v4 contain their private key.
Details
Background
Recently, I encountered an API in Go that’s easy to misuse: sha512.Sum384 and sha512.New384().Sum look very similar and behave very differently. https://go.dev/play/p/kDCqqoYk84k demonstrates this. I want to discuss extending static analysis to detect this case with the go community, but before I do that, I want to make a best-effort pass at open-source projects to fix the existing bugs. I figured that if there were any vulnerabilities out there, they would be easy to find once that discussion begins, so it’s better to address them early.
This work is a hobby project and has no affiliation with my employer, so I may be slow to respond due to existing commitments.
PoC
https://go.dev/play/p/vSW0U3Hq4qk
Impact
This code (cert.NewLeaf) generates certs with the SubjectKeyId set to sha512.New384().Sum(/* private */ key)
.
If a cert which was generated by cert.NewLeaf is transferred over the network in plaintext, as is often the case in TLS handshakes, an attacker listening on that network may sniff the cert and trivially extract the private key from it. This applies to client and server TLS certs generated by vulnerable versions of this library.
Getting the server cert and its key would only require performing a TLS handshake (with a matching SNI) with the server. At that point, the attacker could impersonate the server.
Similarly, getting the client cert and its key would require getting the client to perform a TLS handshake against an attacker-controlled server. At that point, an attacker could impersonate the client.
{ "affected": [ { "database_specific": { "last_known_affected_version_range": "\u003c= 4.0.3" }, "package": { "ecosystem": "Go", "name": "github.com/juju/utils/v4/cert" }, "ranges": [ { "events": [ { "introduced": "0" }, { "fixed": "4.0.4" } ], "type": "ECOSYSTEM" } ] } ], "aliases": [ "CVE-2025-6224" ], "database_specific": { "cwe_ids": [ "CWE-312" ], "github_reviewed": true, "github_reviewed_at": "2025-07-01T17:35:16Z", "nvd_published_at": "2025-07-01T11:15:21Z", "severity": "MODERATE" }, "details": "### Summary\n\nCerts generated by v4 contain their private key.\n\n## Details\n\n### Background\n\nRecently, I encountered an API in Go that\u2019s easy to misuse: sha512.Sum384 and sha512.New384().Sum look very similar and behave very differently. https://go.dev/play/p/kDCqqoYk84k demonstrates this. I want to discuss extending static analysis to detect this case with the go community, but before I do that, I want to make a best-effort pass at open-source projects to fix the existing bugs. I figured that if there were any vulnerabilities out there, they would be easy to find once that discussion begins, so it\u2019s better to address them early. \n\nThis work is a hobby project and has no affiliation with my employer, so I may be slow to respond due to existing commitments. \n\n### PoC\n\nhttps://go.dev/play/p/vSW0U3Hq4qk\n\n### Impact\n\n[This code](https://github.com/juju/utils/blob/0141ef0ee74a0cac603c5c9e4aff194008722f41/cert/cert.go#L120) (cert.NewLeaf) generates certs with the SubjectKeyId set to `sha512.New384().Sum(/* private */ key)`.\n\nIf a cert which was generated by cert.NewLeaf is transferred over the network in plaintext, as is often the case in TLS handshakes, an attacker listening on that network may sniff the cert and trivially extract the private key from it. This applies to client and server TLS certs generated by vulnerable versions of this library.\n\nGetting the server cert and its key would only require performing a TLS handshake (with a matching SNI) with the server. At that point, the attacker could impersonate the server.\n\nSimilarly, getting the client cert and its key would require getting the client to perform a TLS handshake against an attacker-controlled server. At that point, an attacker could impersonate the client.", "id": "GHSA-h34r-jxqm-qgpr", "modified": "2025-07-01T17:35:16Z", "published": "2025-07-01T17:35:16Z", "references": [ { "type": "WEB", "url": "https://github.com/juju/utils/security/advisories/GHSA-h34r-jxqm-qgpr" }, { "type": "ADVISORY", "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-6224" }, { "type": "WEB", "url": "https://github.com/juju/utils/commit/766f27d7bcd10433453a9764509a864c17a46a76" }, { "type": "PACKAGE", "url": "https://github.com/juju/utils" }, { "type": "WEB", "url": "https://github.com/juju/utils/releases/tag/v4.0.4" } ], "schema_version": "1.4.0", "severity": [ { "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N", "type": "CVSS_V3" } ], "summary": "juju/utils leaks private key in certs" }
Sightings
Author | Source | Type | Date |
---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
- Confirmed: The vulnerability is confirmed from an analyst perspective.
- Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
- Patched: This vulnerability was successfully patched by the user reporting the sighting.
- Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
- Not confirmed: The user expresses doubt about the veracity of the vulnerability.
- Not patched: This vulnerability was not successfully patched by the user reporting the sighting.