CVE-2026-119186: Forge: AES-GCM authentication bypass via unvalidated tagLength option
node-forge 1.4.0 and earlier accept any AES-GCM ciphertext as authentic when the application passes a zero-like tagLength (0, null, false, '' or '0') to the decipher and the tag is empty. An attacker who can send a message with an empty tag can forge data. Upgrade to node-forge 1.4.1, which rejects invalid tag lengths.
Published Oct 30, 2026 · Analysis Oct 31, 2026
What an attacker can do
In modes.gcm.prototype.start() (lib/cipherModes.js), forge stored the tagLength option without checking it. When it converts to 0, afterFinish() computes truncate(16 % (tagLength / 8)), which is 16 % 0 = NaN, and the tag becomes empty. On decryption the length check on the supplied tag passes for an empty tag, and the final comparison compares two empty strings. So decipher.finish() returns true for any ciphertext and any additional data.
The flaw needs a specific usage pattern. The application must pass a zero-like tagLength. Typical cases are a tag length derived from the received tag (receivedTag.length * 8) or an unset configuration value. The default (no tagLength, 128 bits) and any fixed valid tag length are not affected.
An attacker with network access who can send a ciphertext with an empty tag can make such an application accept attacker-chosen data as authentic. GCM is a stream cipher, so an attacker who knows part of a captured plaintext can also change it to chosen values. The impact is on integrity only (CVSS C:N/I:H/A:N), and attack complexity is rated high because of the usage precondition.
Who is affected
node-forge up to and including 1.4.0 on npm. Only code that calls forge.cipher.createDecipher('AES-GCM', key) and then start() with a tagLength that can be 0, null, false, an empty string or '0' is exposed. Check the installed version, including transitive copies:
npm ls node-forgeThen search your code for tagLength near AES-GCM start() calls and see whether the value comes from received data or from optional configuration.
node-forge
- Ecosystem
- npm
- Affected
- <= 1.4.0
- Fixed in
- 1.4.1
- Check
npm ls node-forge
How to fix it
Upgrade to node-forge 1.4.1:
npm install [email protected]In 1.4.1, start() throws "Invalid tag length." unless tagLength is 128, 120, 112, 104, 96, 64 or 32 bits. A missing, null or undefined value means the default of 128 bits. Numeric strings such as '128' are still accepted.
Workaround if you cannot upgrade: never derive tagLength from received data. Pass a fixed value or omit it, and check the received tag length first, for example if(tag.length !== 16) { throw new Error('Invalid tag.'); } before decipher.start({iv: iv, tag: tag});.
How to tell if you were hit
Review code and wrappers that call forge AES-GCM decryption. Flag any start() call whose tagLength is computed from the tag (tag.length * 8) or read from optional settings. In logs, look for messages accepted with an empty or missing authentication tag, or decryption of ciphertext that was never produced by your own encryption path. After upgrading, such calls fail with "Invalid tag length.", so watch for that error as a sign of malformed input or a bug in the caller.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
Summary
The AES-GCM mode in forge.cipher does not validate the tagLength option passed to start(). With a tagLength of 0 or a value that converts to 0 (such as null, false, '' or '0'), the authentication tag is empty, and decipher.finish() returns true for any ciphertext and additional data when the supplied tag is empty or missing. Fixed in node-forge 1.4.1.
Details
modes.gcm.prototype.start() in lib/cipherModes.js stored the tagLength option without validation, and lib/cipher.js documented it as accepting "0-128". After processing the data, afterFinish() truncates the 16-byte tag with truncate(16 % (tagLength / 8)). For a tagLength that converts to 0, this is 16 % 0 = NaN, and truncating by NaN empties the tag. On decryption, the start-time check that the supplied tag has tagLength / 8 bytes passes for an empty tag, and the final tag comparison compares two empty strings, so decipher.finish() returns true for any ciphertext and additional data.
NIST SP 800-38D section 5.2.1.2 allows only tag lengths of 128, 120, 112, 104 and 96 bits, plus 64 and 32 bits for certain applications.
The fix validates tagLength in start(), for both encryption and decryption. A missing, null or undefined tagLength uses the default of 128 bits. Any other value is converted with Number() and must be one of 128, 120, 112, 104, 96, 64 or 32; otherwise start() throws "Invalid tag length.". Numeric strings such as '128' are still accepted. With a validated tagLength, an empty tag no longer matches the expected tag length and is rejected.
Patches
Fixed in node-forge 1.4.1. cipher.start() now throws an error unless tagLength is one of the tag lengths allowed by NIST SP 800-38D (128, 120, 112, 104, 96, 64 or 32 bits); a null or undefined tagLength means the default of 128 bits.
Workarounds
Do not derive tagLength from received data. Pass a fixed tagLength (or omit it to use the default of 128 bits), and check that the received tag has the expected length before calling start(), for example if(tag.length !== 16) { throw new Error('Invalid tag.'); } before decipher.start({iv: iv, tag: tag});.
Proof of concept
Start an AES-GCM decipher with tagLength: 0 and an empty tag, as an application does when it derives the tag length from a received empty tag, and feed it arbitrary bytes that were never encrypted under the key:
var decipher = forge.cipher.createDecipher('AES-GCM', key);
decipher.start({iv: iv, tag: '', tagLength: 0});
decipher.update(forge.util.createBuffer('any attacker-chosen bytes'));
decipher.finish();
// <= 1.4.0: true
// 1.4.1: start() throws "Invalid tag length."tagLength values null, false and '0' (with an empty tag), and tagLength: 0 with no tag option, give the same result on <= 1.4.0. The fix adds regression tests in tests/unit/aes.js.
Impact
Applications that decrypt AES-GCM data with forge.cipher.createDecipher() ('AES-GCM') and pass a zero-like tagLength are affected. Typical cases are a tag length derived from the received tag, or an unset configuration value:
var decipher = forge.cipher.createDecipher('AES-GCM', key);
decipher.start({iv: iv, tag: receivedTag, tagLength: receivedTag.length * 8});
decipher.update(forge.util.createBuffer(receivedCiphertext));
if(decipher.finish()) { /* attacker-supplied data accepted */ }An attacker who can send a ciphertext with an empty tag to such an application can make it accept attacker-chosen ciphertext as authentic. Because GCM encryption is a stream cipher, an attacker who knows (part of) a captured message's plaintext can also change that plaintext to chosen values. The default (no tagLength option, 128 bits) and any fixed valid tagLength are not affected.
Questions
- Is the default forge AES-GCM usage affected by this bug?
No. If you omit tagLength, forge uses 128 bits and the empty-tag bypass does not occur. A fixed valid tagLength is also safe. Only a tagLength that converts to 0 triggers the flaw.
- Which node-forge version fixes CVE-2026-119186?
node-forge 1.4.1. Versions 1.4.0 and earlier are vulnerable. The fix validates tagLength in start() for both encryption and decryption and throws "Invalid tag length." for disallowed values.
- Can an attacker exploit this remotely?
Yes, if your service decrypts attacker-supplied AES-GCM messages and derives the tag length from the received tag or an unset setting. The attacker sends a ciphertext with an empty tag. The advisory rates it medium (5.9) because that usage pattern is required.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
More npm vulnerabilities
All npm entriesCVE-2026-118774
Forge: Certificate signature verified with the issuer's RSA signature scheme
low3.7Nov 10, 2026CVE-2026-118776
Forge: Incomplete PKCS#7 padding validation in AES/DES CBC and ECB decryption
low3.7Nov 10, 2026CVE-2026-119189
Forge: X.509 pathLenConstraint not enforced by verifyCertificateChain() for CA certificates without keyUsage
medium5.9Nov 10, 2026CVE-2026-119191
Forge: ASN.1 resource exhaustion via BIT STRING decoding in asn1.fromDer
high7.5Nov 10, 2026CVE-2026-119192
Forge: RSA PKCS#1 v1.5 signature forgery via non-canonical DigestInfo encoding
high7.5Nov 10, 2026CVE-2026-125332
Forge: TLS client crash on an unsupported ServerHello compression method
medium5.9Nov 10, 2026
