First published: Wed Sep 27 2023(Updated: )
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: ```js 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: ```js '\t'.repeat(54773) + '\t/function/i' ``` Here is a simple PoC code to demonstrate the issue: ```js 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"); ```
Affected Software | Affected Version | How to fix |
---|---|---|
npm/get-func-name | <2.0.1 | 2.0.1 |
Sign up to SecAlerts for real-time vulnerability data matched to your software, aggregated from hundreds of sources.
The vulnerability ID is GHSA-4q6p-r6v2-jvc5.
The severity rating of GHSA-4q6p-r6v2-jvc5 is high with a value of 8.6.
The vulnerability is due to the current regex implementation for parsing values in the module, which is susceptible to excessive backtracking, potentially leading to DoS attacks.
This vulnerability can be exploited by an attacker performing malicious input that causes excessive backtracking during value parsing.
Yes, the fix for GHSA-4q6p-r6v2-jvc5 is available in version 2.0.1 of the 'get-func-name' npm package.