CVE-2023-43646
JSON

8.6high

Inefficient Regular Expression Complexity in get-func-name

Severity
8.6high CVSS:3.1 by GitHub_M
Exploit likelihood
1.38% (higher than 72% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-4q6p-r6v2-jvc5

Description

get-func-name is a module to retrieve a function's name securely and consistently both in NodeJS and the browser. Versions prior to 2.0.1 are subject to a regular expression denial of service (redos) vulnerability which may lead to a denial of service when parsing malicious input. This vulnerability can be exploited when there is an imbalance in parentheses, which results in excessive backtracking and subsequently increases the CPU load and processing time significantly. This vulnerability can be triggered using the following input: '\t'.repeat(54773) + '\t/function/i'. This issue has been addressed in commit `f934b228b` which has been included in releases from 2.0.1. Users are advised to upgrade. There are no known workarounds for this vulnerability.

Affected

Product or packageVersionsReported by
chaijs get-func-name< 2.0.1, before 2.0.1CVE List, NVD
get-func-name (npm)before 2.0.1GitHub Advisory Database

All scores

GitHub_M8.6high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:N/I:N/A:H
GitHub7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
NVD7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Classification

CWE-400CWE-1333

SSVC (CISA-ADP): exploitation poc, automatable yes, technical impact partial.

What each source says

CVE List

get-func-name is a module to retrieve a function's name securely and consistently both in NodeJS and the browser. Versions prior to 2.0.1 are subject to a regular expression denial of service (redos) vulnerability which may lead to a denial of service when parsing malicious input. This vulnerability can be exploited when there is an imbalance in parentheses, which results in excessive backtracking and subsequently increases the CPU load and processing time significantly. This vulnerability can be triggered using the following input: '\t'.repeat(54773) + '\t/function/i'. This issue has been addressed in commit `f934b228b` which has been included in releases from 2.0.1. Users are advised to upgrade. There are no known workarounds for this vulnerability.

GitHub Advisory Database

The current regex implementation for parsing values in the module is susceptible to excessive backtracking, leading to potential DoS attacks. The regex implementation in question is as follows:

const functionNameMatch = /\s*function(?:\s|\s*\/\*[^(?:*/)]+\*\/\s*)*([^\s(/]+)/;

This vulnerability can be exploited when there is an imbalance in parentheses, which results in excessive backtracking and subsequently increases the CPU load and processing time significantly. This vulnerability can be triggered using the following input:

'\t'.repeat(54773) + '\t/function/i'

Here is a simple PoC code to demonstrate the issue:

const protocolre = /\sfunction(?:\s|\s/*[^(?:*\/)]+*/\s*)*([^\(\/]+)/;

const startTime = Date.now();
const maliciousInput = '\t'.repeat(54773) + '\t/function/i'

protocolre.test(maliciousInput);

const endTime = Date.now();

console.log("process time: ", endTime - startTime, "ms");
NVD (es)

get-func-name es un módulo para recuperar el nombre de una función de forma segura y consistente tanto en NodeJS como en el navegador. Las versiones anteriores a la 2.0.1 están sujetas a una vulnerabilidad de denegación de servicio de expresión regular (redos) que puede provocar una denegación de servicio al analizar entradas maliciosas. Esta vulnerabilidad se puede aprovechar cuando hay un desequilibrio entre paréntesis, lo que da como resultado un retroceso excesivo y, posteriormente, aumenta significativamente la carga de la CPU y el tiempo de procesamiento. Esta vulnerabilidad se puede activar utilizando la siguiente entrada: '\t'.repeat(54773) + '\t/function/i'. Este problema se solucionó en el commit `f934b228b` que se incluyó en las versiones 2.0.1. Se recomienda a los usuarios que actualicen. No se conocen workarounds para esta vulnerabilidad.

References

Sources

SourceRecordLicence
CVE ListCVE-2023-43646 changed 2024-09-24CVE Terms of Use
GitHub Advisory DatabaseGHSA-4q6p-r6v2-jvc5 changed 2026-08-07CC-BY-4.0
NVDCVE-2023-43646 changed 2026-06-17Public domain