CVE-2020-36650 (published 2023-01-11T18:15Z)

A vulnerability, which was classified as critical, was found in IonicaBizau node-gry up to 5.x. This affects an unknown part. The manipulation leads to command injection. Upgrading to version 6.0.0 is able to address this issue. The patch is named 5108446c1e23960d65e8b973f1d9486f9f9dbd6c. It is recommended to upgrade the affected component. The associated identifier of this vulnerability is VDB-218019.

CVSS v3 base score: 8.0, HIGH (CVSS:3.1/AV:A/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-77
cwe_name: Improper Neutralization of Special Elements used in a Command ('Command Injection')
description: The product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.
extended_description: 
            Many protocols and products have their own custom command language. While OS or shell command strings are frequently discovered and targeted, developers may not realize that these other command languages might also be vulnerable to attacks.
         
         

Fix information:
repo_url: https://github.com/IonicaBizau/node-gry
commit_details: repo_url: https://github.com/IonicaBizau/node-gry
author: jammy
author_date: 2020-04-03 23:58:55+02:00
msg: fix command injection vulnerability
repository: repo_url: https://github.com/IonicaBizau/node-gry
repo_name: IonicaBizau/node-gry
description: :seat: A minimalist NodeJS wrapper for the `git` commands. `gry` stands for the Git RepositorY.
repo_language: JavaScript
owner: IonicaBizau
file_changes: filename: index.js
change_type: ModificationType.MODIFY
diff: @@ -16,7 +16,7 @@ oneByOne([
     }
   , cb => {
         console.log("> Created README.md");
-        myRepo.exec("add .", cb);
+        myRepo.exec(['add', '.'], cb);
     }
   , cb => {
         console.log("> Added the files.");

programming_language: JavaScript
filename: index.js
change_type: ModificationType.MODIFY
diff: @@ -52,20 +52,12 @@ class Gry {
      * @return {Gry} The `Gry` instance.
      */
     exec (command, args, callback) {
-
         var eargs = [];
         if (typeof args === "function") {
             callback = args;
             args = null;
         }
 
-        // Handle spawn
-        if (Array.isArray(args)) {
-            eargs.push("git", [command].concat(args));
-        } else {
-            eargs.push("git " + command.trim());
-        }
-
         eargs.push({ cwd: this.cwd });
 
         // Add the callback function
@@ -73,8 +65,9 @@ class Gry {
             if (err) { return callback(err); }
             callback(null, stdout.trimRight());
         });
+        console.log({command, eargs, callback})
 
-        el.add.apply(el, eargs);
+        el.add('git', command, eargs[0], eargs[1]);
         return this;
     }
 
@@ -88,7 +81,7 @@ class Gry {
      * @return {Gry} The `Gry` instance.
      */
     init (callback) {
-        return this.exec("init", callback);
+        return this.exec(['init'], callback);
     }
 
     /**
@@ -128,7 +121,7 @@ class Gry {
             callback = options;
             options = "";
         }
-        return this.exec("commit -m \"" + message + "\" " + options, callback)
+        return this.exec(['commit', '-m', message, ...options.split(' ').filter(a => a)], callback)
     }
 
     /**
@@ -146,7 +139,7 @@ class Gry {
             callback = options;
             options = "";
         }
-        return this.exec("pull " + options, callback);
+        return this.exec(['pull', ...options.split(' ')], callback);
     }
 
     /**
@@ -164,7 +157,7 @@ class Gry {
             callback = options;
             options = ".";
         }
-        return this.exec("add " + options, callback);
+        return this.exec(['add', ...options.split(' ')], callback);
     }
 
     /**
@@ -182,7 +175,7 @@ class Gry {
             callback = options;
             options = "";
         }
-        return this.exec("branch " + options, callback);
+        return this.exec(['branch', ...options.split(' ')], callback);
     }
 
     /**
@@ -200,7 +193,7 @@ class Gry {
             callback = options;
             options = "";
         }
-        return this.exec("checkout " + options, callback);
+        return this.exec(['checkout', ...options.split(' ')], callback);
     }
 
     /**
@@ -219,7 +212,7 @@ class Gry {
             callback = options;
             options = "";
         }
-        return this.exec("clone " + gitUrl + " " + options, callback);
+        return this.exec(['clone', gitUrl, ...options.split(' ')], callback);
     }
 }
 

programming_language: JavaScript