CVE-2020-7609 (published 2020-04-27T22:15Z)

node-rules including 3.0.0 and prior to 5.0.0 allows injection of arbitrary commands. The argument rules of function "fromJSON()" can be controlled by users without any sanitization.

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

Weakness information:
cwe_id: CWE-94
cwe_name: Improper Control of Generation of Code ('Code Injection')
description: The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.
extended_description: 
            When a product allows a user's input to contain code syntax, it might be possible for an attacker to craft the code in such a way that it will alter the intended control flow of the product. Such an alteration could lead to arbitrary code execution.
            Injection problems encompass a wide variety of issues -- all mitigated in very different ways. For this reason, the most effective way to discuss these weaknesses is to note the distinct features which classify them as injection weaknesses. The most important issue to note is that all injection problems share one thing in common -- i.e., they allow for the injection of control plane data into the user-controlled data plane. This means that the execution of the process may be altered by sending code in through legitimate data channels, using no other mechanism. While buffer overflows, and many other flaws, involve the use of some further issue to gain execution, injection problems need only for the data to be parsed. The most classic instantiations of this category of weakness are SQL injection and format string vulnerabilities.
         
         

Fix information:
repo_url: https://github.com/mithunsatheesh/node-rules
commit_details: repo_url: https://github.com/mithunsatheesh/node-rules
author: Mithun Satheesh
author_date: 2020-03-16 19:13:37+05:30
msg: Remove fromJSON and toJSON from exposed APIs

Remove fromJSON and toJSON from exposed APIs in V5.0.0
repository: repo_url: https://github.com/mithunsatheesh/node-rules
repo_name: mithunsatheesh/node-rules
description: Node-rules is a light weight forward chaining rule engine that can be used in JavaScript and TypeScript based projects.
repo_language: TypeScript
owner: mithunsatheesh
file_changes: filename: node-rules.js
change_type: ModificationType.MODIFY
diff: @@ -128,36 +128,5 @@
         }
         this.sync();
     }
-    RuleEngine.prototype.toJSON = function() {
-        var rules = this.rules;
-        if (rules instanceof Array) {
-            rules = rules.map(function(rule) {
-                rule.condition = rule.condition.toString();
-                rule.consequence = rule.consequence.toString();
-                return rule;
-            });
-        } else if (typeof(rules) != "undefined") {
-            rules.condition = rules.condition.toString();
-            rules.consequence = rules.consequence.toString();
-        }
-        return rules;
-    };
-    RuleEngine.prototype.fromJSON = function(rules) {
-        this.init();
-        if (typeof(rules) == "string") {
-            rules = JSON.parse(rules);
-        }
-        if (rules instanceof Array) {
-            rules = rules.map(function(rule) {
-                rule.condition = eval("(" + rule.condition + ")");
-                rule.consequence = eval("(" + rule.consequence + ")");
-                return rule;
-            });
-        } else if (rules !== null && typeof(rules) == "object") {
-            rules.condition = eval("(" + rules.condition + ")");
-            rules.consequence = eval("(" + rules.consequence + ")");
-        }
-        this.register(rules);
-    };
     module.exports = RuleEngine;
 }(module.exports));

programming_language: JavaScript