Investigate in your agent.

Turn this advisory into a focused investigation. Ask your agent to check your project’s versions, explain the evidence, and suggest a compatible fix.

Your agent needs remote MCP support and access to https://cve.new/mcp.

Read the setup guide

Skip to content
Check your stack
CVE-2026-118779high7.5

Forge: Regular expression denial of service in PEM decoding (pem.decode)

Impact

The node-forge library, specifically versions before 1.4.1, contains a regular expression denial of service vulnerability in PEM decoding. A remote attacker can cause the Node.js event loop to block for seconds to minutes with a crafted input. The vulnerability affects any application that passes untrusted PEM text to node-forge.

Summarized by @cf/meta/llama-3.3-70b-instruct-fp8-fast. Verify details against the original sources.
Applies when

Proof of concept

var forge = require('node-forge');
var pem = ' -----BEGIN I-----G-----END B'.repeat(1000) + '\x00'; // 29 KB
try {
  forge.pki.certificateFromPem(pem);
} catch(e) {}

Affected packages

Start with the recorded fix for your release branch. Check your installed version and test compatibility before upgrading. Fixing this advisory does not rule out other vulnerabilities in the release.

Affected range Recorded fix
Earlier releases before 1.4.1Semantic versions1.4.1

Version evidence: OSV · GHSA-7wch-p9px-956x

View original version evidence (0 explicit versions)

Affected products

Vendor version evidence. Product records are separate from automatic dependency matching.

digitalbazaar · GitHub_M

forge

1 range

Compare with this publisher’s ranges. This does not inspect your installation.

affected

< 1.4.1

unaffected

unknown

Other versions: unknown

Original source description

Summary

pem.decode(), which every node-forge API that parses PEM input uses, split messages with a regular expression that takes polynomial time on input without a matching END line, and parsed encapsulated headers with regular expressions that take quadratic time on long header lines. A remote attacker can block the Node.js event loop for seconds to minutes with a crafted input of a few tens of kilobytes. Fixed in node-forge 1.4.1.

Details

pem.decode() in lib/pem.js found PEM messages with this regular expression:

/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g

The optional headers group and the body group are adjacent, lazy, and share characters (whitespace and the base64 alphabet), and the match must end with an END line whose label equals the BEGIN label (\1). When no such END line follows, the engine tries every split of the text between the two groups, for every label split and at every BEGIN line in the input. The work grows polynomially with the input length (roughly cubic for repeated BEGIN/END lines with mismatched labels, quadratic for a BEGIN line followed by many newlines).

The encapsulated header parsing in the same function had two smaller quadratic cases: trimming each header line with /\s+$/, and an unanchored header regex ([\x21-\x7e]+):... that retries at every position of a long line without a colon. These are reachable when a message does match.

All PEM entry points call pem.decode(), including pki.certificateFromPem(), pki.privateKeyFromPem(), pki.publicKeyFromPem(), pki.certificationRequestFromPem(), pki.encryptedPrivateKeyFromPem(), pki.decryptRsaPrivateKey() and pkcs7.messageFromPem().

The fix replaces the message regular expression with a scanner that indexes the END lines once and matches each BEGIN line in linear time, finding the same messages as before. The one difference: a label containing ----- (-----BEGIN A-----B-----) was matched as A-----B if possible; now only the shortest label, A, is used. RFC 7468 labels can't contain --. Header parsing now trims lines with a loop and only starts a header match at the beginning of a run of printable characters, which gives the same result.

Patches

Fixed in node-forge 1.4.1. PEM messages and encapsulated headers are now parsed in linear time.

Workarounds

Rejecting untrusted PEM input larger than a few kilobytes before passing it to node-forge limits the delay but doesn't remove it: on 1.4.0, about 7 KB of crafted input blocked for 0.4 s, and 29 KB for 24 s.

Credits

Reported by Ahmed Mokhtari (@AhmedMokhtari), @mwlik and @imenyoo2, and independently by @offset, @bibu123456 (coordinated by @Kayiz-PT), and @Mucahic.

Proof of concept

var forge = require('node-forge');
var pem = ' -----BEGIN I-----G-----END B'.repeat(1000) + '\x00'; // 29 KB
try {
  forge.pki.certificateFromPem(pem);
} catch(e) {}

On 1.4.0 (Node.js 24) this call blocks for about 24 seconds before throwing "Invalid PEM formatted message."; 14 KB takes about 3 seconds. A BEGIN line followed by 32 KB of newlines and no END line takes about 1.5 seconds, and the time grows quadratically from there. On 1.4.1 each of these inputs is rejected in a few milliseconds, and 1 MB inputs of any of these shapes take under 100 ms.

The PoC is in tests/pocs/ghsa-7wch-p9px-956x.js. Regression tests are in tests/unit/pem.js ("GHSA-7wch-p9px-956x ReDoS checks").

Impact

Any application that passes untrusted PEM text to node-forge is affected: for example, services that accept uploaded certificates, keys or certificate signing requests, or that parse certificates from configuration, SAML metadata or other user-supplied documents. A remote, unauthenticated attacker can send a small crafted input that blocks the Node.js event loop for seconds to minutes per request, so the process stops serving other requests. Repeated requests keep it unavailable. There is no confidentiality or integrity impact.

Inside the record

Evidence available

Package identity
Version evidence
Remediation guidance · not supplied
Weakness classification
Additional publishers

Describes the evidence in this view, not whether the product is safe.

Original records

CVE-2026-118779

View the latest unmodified CVE JSON from the official source. It may be newer than this imported page.

cve.new JSON →

Underlying weaknesses

The source’s classification of what caused the vulnerability.

CWE-400 ↗

CWE-400: Uncontrolled Resource Consumption

GitHub_M

Related →
CWE-1333 ↗

CWE-1333: Inefficient Regular Expression Complexity

GitHub_M

Related →
Contributing organizations · 2
GitHub_M

Assigning organization

2026-10-29
CISA-ADP

Additional data publisher

2026-10-29

What changed

Follow changes
  1. CVE · CVE-2026-118779

    Observed 2026-10-29T21:08:11.099Z · upstream updated 2026-10-29T20:23:11.602Z

    Prioritization updated

    before

    []

    after

    [
      {
        "source": "CISA-ADP",
        "type": "SSVC",
        "role": "CISA Coordinator",
        "timestamp": "2026-10-29T20:22:46.362205Z",
        "decisions": [
          {
            "name": "Exploitation",
            "value": "poc"
          },
          {
            "name": "Automatable",
            "value": "yes"
          },
          {
            "name": "Technical Impact",
            "value": "partial"
          }
        ]
      }
    ]

Large field values are marked as truncated previews. Original source snapshots remain retained.

Showing up to 50 most recent observed changes.

References

5 sources