node-forgeAny downstream application using these components is impacted.
These components may be leveraged by downstream applications in ways that enable full compromise of integrity, leading to potential availability and confidentiality compromises.
| Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
|---|---|---|---|
| node-forge | npm | < 1.3.2 | 1.3.2 |
The root cause of the vulnerability is an interpretation conflict in the asn1.validate function in lib/asn1.js. The flaw lies in the handling of optional elements within an ASN.1 schema. When an optional element failed validation, the parser would not advance to the next data segment. This desynchronization allowed a subsequent schema element to be validated against the same, incorrect data. An attacker could exploit this by crafting a malicious ASN.1 structure where a malformed optional field's data is misinterpreted as a valid, different, and mandatory field, effectively bypassing security controls.
The primary patch was applied directly to asn1.validate, correcting the faulty loop logic to ensure the parser state remains synchronized. The vulnerability's impact extends to several higher-level functions that consume ASN.1 data, such as those for handling PKCS#12, X.509, PKCS#7, and cryptographic keys. For instance, the p12.pkcs12FromAsn1 function was patched with an additional check to mitigate the risk of a MAC (Message Authentication Code) bypass. During an exploit, a profiler would show a stack trace originating from one of these higher-level parsing functions (e.g., p12.pkcs12FromAsn1) which then calls the core vulnerable function, asn1.validate.
asn1.validatelib/asn1.js
p12.pkcs12FromAsn1lib/pkcs12.js
x509.certificateFromAsn1lib/x509.js
pkcs7.messageFromAsn1lib/pkcs7.js
rsa.publicKeyFromAsn1lib/rsa.js
rsa.privateKeyFromAsn1lib/rsa.js
ed25519.publicKeyFromAsn1lib/ed25519.js