crypto.X509Certificate.toLegacyObject doesn't propagate internal OpenSSL errors
Personne n'a encore pris cette issue.
- Langage dominant
- JavaScript
- Étoiles
- 122k
- Forks
- 37.3k
- Merge moyen
- 4 j 2 h
- PR mergées (30 j)
- 283
Description
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?
For context, consider this JavaScript code as an illustrative example:
const { X509Certificate } = require('crypto');
const fs = require('fs');
console.log((new X509Certificate(fs.readFileSync('test/fixtures/x509-escaping/alt-28-cert.pem'))).toLegacyObject());
Various values are fetched from a certificate to put into an object here:
Various of these functions can actually fail internally in OpenSSL, but this isn't propagated via an exception. So it is impossible to distinguish between a certificate that doesn't have a certain value or a failure.
For example, a failure somewhere in this code for example will cause the absence of the subjectaltname property of the returned object:
More specifically, our testing framework reported these concerns specifically for the following OpenSSL calls that can fail:
`OBJ_obj2nid` via `ncrypto::X509Name::Iterator::operator*[abi:cxx11]() const+0x5ad` with return value `0`
`BN_bn2hex` via `ncrypto::BignumPointer::toHex() const+0x58` with return value `0`
`ASN1_INTEGER_to_BN` via `ncrypto::X509View::getSerialNumber() const+0x180` with return value `0`
`BIO_new` via `ncrypto::X509View::getInfoAccess() const+0x14f` with return value `0`
`BIO_new` via `ncrypto::X509View::getValidFrom() const+0x14f` with return value `0`
`BIO_new` via `ncrypto::X509View::getSubjectAltName() const+0x14f` with return value `0`
`BIO_new` via `ncrypto::X509View::getValidTo() const+0x14f` with return value `0`
`X509_get_ext_by_NID` via `ncrypto::X509View::getInfoAccess() const+0x1bd` with return value `0`
`X509_get_ext_by_NID` via `ncrypto::X509View::getSubjectAltName() const+0x1bd` with return value `0`
`i2d_X509_bio` via `ncrypto::X509View::toDER() const+0x1c4` with return value `0`
`ASN1_TIME_print` via `ncrypto::X509View::getValidFrom() const+0x1cc` with return value `0`
`ASN1_TIME_print` via `ncrypto::X509View::getValidTo() const+0x1cc` with return value `0`
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.
What do you see instead?
The property will not be added to the object, making it impossible to detect whether a property is absent from the certificate or if there was an internal error in OpenSSL.
Additional information
Found by an experimental static-hybrid analyzer I'm working on.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par les lignes 774-794 de src/crypto/crypto_x509.cc et les lignes 1086-1097 de deps/ncrypto/ncrypto.cc, puis examinez les appels OpenSSL indiqués et leur gestion des erreurs. Reproduisez le problème avec l’exemple X509Certificate et test/fixtures/x509-escaping/alt-28-cert.pem. Le travail est terminé lorsque les échecs internes d’OpenSSL peuvent être distingués des propriétés de certificat absentes au moyen d’une exception.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- cpp, javascript, nodejs
- Domaine
- backend, security
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- Active
- Clarté
- Plutôt claire
- Accessibilité débutants
- 52/100