CVE-2026-118775: ASN.1 OID First Arc Truncation and Ambiguity in node-forge
Vulnerability ID: CVE-2026-118775
CVSS Score: 3.7
Published: 2026-10-30
CVE-2026-118775 (GHSA-4642-5mcj-2rqw) is an integer overflow and validation flaw in the ASN.1 serialization module of Forge (node-forge) prior to version 1.4.1. The asn1.oidToDer() function fails to validate the range of the first two arcs of an Object Identifier (OID) and truncates the packed initial subidentifier to a single 8-bit integer. Applications that perform policy checks on untrusted OID strings before encoding them into Distinguished Encoding Rules (DER) format can be tricked into emitting DER bytes that correspond to a completely different, restricted OID.
TL;DR
In node-forge versions prior to 1.4.1, asn1.oidToDer() does not validate the first two arcs of an OID string and truncates their combined value to 8 bits. This allows crafted OID strings (such as 0.42.840.113549.1.1.1) to bypass string-based allowlists or denylists while serializing into valid DER bytes for restricted OIDs (such as 1.2.840.113549.1.1.1 for rsaEncryption). Upgrade to node-forge 1.4.1 or later to resolve this issue.
⚠️ Exploit Status: POC
Technical Details
- Vulnerability ID: CVE-2026-118775 / GHSA-4642-5mcj-2rqw
- Weakness Class: CWE-190 (Integer Overflow or Wraparound)
- Affected Component: asn1.oidToDer() in lib/asn1.js (node-forge < 1.4.1)
- Attack Vector: Network (High Attack Complexity)
- CVSS v3.1 Score: 3.7 Low (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:N)
- EPSS Score: 0.313% (24.28th Percentile)
- Impact: Bypass of OID string-based authorization or policy checks via DER aliasing
- Exploit & KEV Status: PoC Available (Unit Tests) / Not in CISA KEV
Affected Systems
- node-forge (npm package)
- forge (JavaScript cryptographic library)
-
node-forge: < 1.4.1 (Fixed in:
1.4.1)
Code Analysis
Commit: e56a3dd
Check and encode the first two OID arcs correctly.
diff --git a/lib/asn1.js b/lib/asn1.js
index 548cbe8..9b9be57 100644
--- a/lib/asn1.js
+++ b/lib/asn1.js
@@ -781,17 +781,25 @@ asn1.oidToDer = function(oid) {
var values = oid.split('.');
var bytes = forge.util.createBuffer();
- // first byte is 40 * value1 + value2
- bytes.putByte(40 * parseInt(values[0], 10) + parseInt(values[1], 10));
- // other bytes are each value in base 128 with 8th bit set except for
- // the last byte for each value
+ // X.660: the first arc is 0, 1 or 2, and the second arc is at most 39
+ // under 0 and 1; other values would encode the same as a different OID
+ var first = parseInt(values[0], 10);
+ var second = parseInt(values[1], 10);
+ if(!(first >= 0 && first <= 2 && second >= 0) ||
+ (first < 2 && second > 39)) {
+ throw new Error('Invalid OID; the first two arcs are out of range.');
+ }
+
+ // the first subidentifier is 40 * value1 + value2; the remaining
+ // subidentifiers are each a single value. every subidentifier is encoded in
+ // base 128 with the 8th bit set on every byte except its last.
var last, valueBytes, value, b;
- for(var i = 2; i < values.length; ++i) {
+ for(var i = 1; i < values.length; ++i) {
// produce value bytes in reverse because we don't know how many
// bytes it will take to store the value
last = true;
valueBytes = [];
- value = parseInt(values[i], 10);
+ value = (i === 1) ? 40 * first + second : parseInt(values[i], 10);
// TODO: Change bitwise logic to allow larger values.
if(value > 0xffffffff) {
throw new Error('OID value too large; max is 32-bits.');
Mitigation Strategies
- Upgrade node-forge to version 1.4.1 or later to enforce ITU-T X.660 bounds and base-128 encoding on the first OID subidentifier.
- Validate untrusted OID strings using a strict regular expression and numerical range check before performing policy comparisons or ASN.1 serialization.
- Perform round-trip verification by decoding the output of asn1.oidToDer() with asn1.derToOid() and confirming exact equality with the validated input string.
Remediation Steps:
- Audit application dependencies (package.json and package-lock.json) to identify direct or transitive usage of node-forge versions prior to 1.4.1.
- Update node-forge by running
npm install node-forge@^1.4.1or updating the version constraint in package.json. - Review application code paths invoking
forge.asn1.oidToDer()to ensure untrusted OID strings are strictly validated against/^(0|[1-9]\d*)(\.(0|[1-9]\d*))+$/prior to policy checks.
References
- GitHub Security Advisory: GHSA-4642-5mcj-2rqw
- Forge Patch Commit e56a3dde8e4e63bae566bb32546eeaf92f515e1e
- Forge Release v1.4.1
- National Vulnerability Database: CVE-2026-118775
- CVE.org Record: CVE-2026-118775
- CVEList V5 JSON Record: CVE-2026-118775
- ITU-T Recommendation X.690 (ASN.1 Encoding Rules)
Read the full report for CVE-2026-118775 on our website for more details including interactive diagrams and full exploit analysis.
Top comments (0)