CVE-2021-3822 (published 2021-09-27T13:15Z)

jsoneditor is vulnerable to Inefficient Regular Expression Complexity

Severity: MEDIUM
CVSS v2 base score: 5.0 (AV:N/AC:L/Au:N/C:N/I:N/A:P)
CVSS v3 base score: 7.5, HIGH (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H)

Weakness information:
cwe_id: CWE-400
cwe_name: Uncontrolled Resource Consumption
description: The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
extended_description: 
            Limited resources include memory, file system storage, database connection pool entries, and CPU. If an attacker can trigger the allocation of these limited resources, but the number or size of the resources is not controlled, then the attacker could cause a denial of service that consumes all available resources. This would prevent valid users from accessing the product, and it could potentially have an impact on the surrounding environment. For example, a memory exhaustion attack against an application could slow down the application as well as its host operating system.
            There are at least three distinct scenarios which can commonly lead to resource exhaustion:
               
                  Lack of throttling for the number of allocated resources
                  Losing all references to a resource before reaching the shutdown stage
                  Not closing/returning a resource after processing
               
            Resource exhaustion problems are often result due to an incorrect implementation of the following situations:
               
                  Error conditions and other exceptional circumstances.
                  Confusion over which part of the program is responsible for releasing the resource.
               
         
         

Fix information:
repo_url: https://github.com/josdejong/jsoneditor
commit_details: repo_url: https://github.com/josdejong/jsoneditor
author: Jos de Jong
author_date: 2021-09-22 09:20:38+02:00
msg: Fix inefficient regex to replace return characters
repository: repo_url: https://github.com/josdejong/jsoneditor
repo_name: josdejong/jsoneditor
description: A web-based tool to view, edit, format, and validate JSON
repo_language: JavaScript
owner: josdejong
file_changes: filename: HISTORY.md
change_type: ModificationType.MODIFY
diff: @@ -3,6 +3,11 @@
 https://github.com/josdejong/jsoneditor
 
 
+## not yet published, version 9.5.6
+
+- Fix inefficient regex to replace return characters. 
+
+
 ## 2021-09-01, version 9.5.5
 
 - Fix `setMode` not throwing an exception anymore in case of a parse error

programming_language: Markdown
filename: util.js
change_type: ModificationType.MODIFY
diff: @@ -399,8 +399,8 @@ export function getInnerText (element, buffer) {
 
   // text node
   if (element.nodeValue) {
-    // remove return characters and the whitespace surrounding return characters
-    const trimmedValue = element.nodeValue.replace(/\s*\n\s*/g, '')
+    // remove return characters and the whitespaces surrounding those return characters
+    const trimmedValue = element.nodeValue.replace(/(\b|^)\s*\n\s*(\b|$)/g, '')
     if (trimmedValue !== '') {
       return buffer.flush() + trimmedValue
     } else {

programming_language: JavaScript