spkac exportPublicKey cannot distinguish between internal failure vs invalid input
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 122k
- Forks
- 37.3k
- Ø Merge
- 4 T. 2 Std.
- Gemergte PRs (30 T.)
- 283
Beschreibung
Version
v25.9.0
Platform
Linux 749dbb0e74fd 6.8.0-106-generic #106-Ubuntu SMP PREEMPT_DYNAMIC Fri Mar 6 07:58:08 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
crypto
What steps will reproduce the bug?
The following code will serve as an example to sketch the scenario:
const { Certificate } = require('crypto');
const spkacString = '...';
console.log(Certificate.exportPublicKey(spkacString));
This will hit the following code path, causing an empty string to be returned:
Note that in the case of a valid spkac but with an internal OpenSSL failure (e.g. allocation failure), it behaves the same as an invalid spkac string. This makes distinguishing between an invalid spkac and an internal failure conditions not possible at the call site.
Furthermore, returning an empty string seems inconsistent with how other similar APIs work, e.g.:
How often does it reproduce? Is there a required condition?
When an allocation failure happens or unspecified other type of failure happens inside OpenSSL, it will reproduce.
What is the expected behavior? Why is that the expected behavior?
I would expect an exception at least in the case of an internal OpenSSL failure. Besides that, it's unexpected that there's an inconsistency in the API design between different export functions. I'd expect the failure handling to be done in a consistent manner.
What do you see instead?
An empty string is returned. At least something to distinguish invalid spkac vs internal failure would be welcome.
Additional information
Found by an experimental static-hybrid analyzer I'm working on.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne bei src/crypto/crypto_spkac.cc ungefähr in den Zeilen 43–44 und vergleiche die Fehlerbehandlung mit src/crypto/crypto_keys.cc ungefähr in den Zeilen 141–143. Verfolge Certificate.exportPublicKey und ermittle, wie sich ungültige SPKAC-Eingaben von einem internen OpenSSL-Fehler unterscheiden. Als erledigt gilt die Aufgabe, wenn diese Ergebnisse unterscheidbar sind und das Verhalten durch geeignete Crypto-Tests abgedeckt ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- cpp, javascript, node.js
- Bereich
- backend-api-design, security
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Aktiv
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 58/100