CVE-2023-26156 (published 2023-11-09T05:15Z)

Versions of the package chromedriver before 119.0.1 are vulnerable to Command Injection when setting the chromedriver.path to an arbitrary system binary. This could lead to unauthorized access and potentially malicious actions on the host system.\r\r**Note:**\r\rAn attacker must have access to the system running the vulnerable chromedriver library to exploit it. The success of exploitation also depends on the permissions and privileges of the process running chromedriver.

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

Weakness information:
cwe_id: CWE-78
cwe_name: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
description: The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.
extended_description: 
		   This weakness can lead to a vulnerability in environments in which the attacker does not have direct access to the operating system, such as in web applications. Alternately, if the weakness occurs in a privileged program, it could allow the attacker to specify commands that normally would not be accessible, or to call alternate commands with privileges that the attacker does not have. The problem is exacerbated if the compromised process does not follow the principle of least privilege, because the attacker-controlled commands may run with special system privileges that increases the amount of damage.
            There are at least two subtypes of OS command injection:
               
				 The application intends to execute a single, fixed program that is under its own control. It intends to use externally-supplied inputs as arguments to that program. For example, the program might use system("nslookup [HOSTNAME]") to run nslookup and allow the user to supply a HOSTNAME, which is used as an argument. Attackers cannot prevent nslookup from executing. However, if the program does not remove command separators from the HOSTNAME argument, attackers could place the separators into the arguments, which allows them to execute their own program after nslookup has finished executing.
				 The application accepts an input that it uses to fully select which program to run, as well as which commands to use. The application simply redirects this entire command to the operating system. For example, the program might use "exec([COMMAND])" to execute the [COMMAND] that was supplied by the user. If the COMMAND is under attacker control, then the attacker can execute arbitrary commands or programs. If the command is being executed using functions like exec() and CreateProcess(), the attacker might not be able to combine multiple commands together in the same line.
               
            From a weakness standpoint, these variants represent distinct programmer errors. In the first variant, the programmer clearly intends that input from untrusted parties will be part of the arguments in the command to be executed. In the second variant, the programmer does not intend for the command to be accessible to any untrusted party, but the programmer probably has not accounted for alternate ways in which malicious attackers can provide input.
         
         

Fix information:
repo_url: https://github.com/giggio/node-chromedriver
commit_details: repo_url: https://github.com/giggio/node-chromedriver
author: Giovanni Bassi
author_date: 2023-11-07 19:06:37-03:00
msg: Hide private attributes from exports
repository: repo_url: https://github.com/giggio/node-chromedriver
repo_name: giggio/node-chromedriver
description: An installer and wrapper for Chromedriver.
repo_language: JavaScript
owner: giggio
file_changes: filename: .npmignore
change_type: ModificationType.MODIFY
diff: @@ -5,6 +5,7 @@ tmp
 Dockerfile
 *.sh
 testInstall.js
+testStart.js
 update.js
 *.tgz
 .vscode

programming_language: Shell
filename: chromedriver.js
change_type: ModificationType.MODIFY
diff: @@ -3,23 +3,23 @@ const path = require('path');
 const tcpPortUsed = require('tcp-port-used');
 function getPortFromArgs(args) {
   let port = 9515;
-  if (!args) {
+  if (!args)
     return port;
-  }
   const portRegexp = /--port=(\d*)/;
   const portArg = args.find(function (arg) {
     return portRegexp.test(arg);
   });
-  if (portArg) {
+  if (portArg)
     port = parseInt(portRegexp.exec(portArg)[1]);
-  }
   return port;
 }
 process.env.PATH = path.join(__dirname, 'chromedriver') + path.delimiter + process.env.PATH;
-exports.path = process.platform === 'win32' ? path.join(__dirname, 'chromedriver', 'chromedriver.exe') : path.join(__dirname, 'chromedriver', 'chromedriver');
-exports.version = '119.0.6045.105';
-exports.start = function (args, returnPromise) {
-  let command = exports.path;
+const crpath = process.platform === 'win32' ? path.join(__dirname, 'chromedriver', 'chromedriver.exe') : path.join(__dirname, 'chromedriver', 'chromedriver');
+const version = '119.0.6045.105';
+let defaultInstance = null;
+
+function start(args, returnPromise) {
+  let command = crpath;
   if (!fs.existsSync(command)) {
     console.log('Could not find chromedriver in default path: ', command);
     console.log('Falling back to use global chromedriver bin');
@@ -28,10 +28,9 @@ exports.start = function (args, returnPromise) {
   const cp = require('child_process').spawn(command, args);
   cp.stdout.pipe(process.stdout);
   cp.stderr.pipe(process.stderr);
-  exports.defaultInstance = cp;
-  if (!returnPromise) {
+  defaultInstance = cp;
+  if (!returnPromise)
     return cp;
-  }
   const port = getPortFromArgs(args);
   const pollInterval = 100;
   const timeout = 10000;
@@ -39,9 +38,20 @@ exports.start = function (args, returnPromise) {
     .then(function () {
       return cp;
     });
-};
-exports.stop = function () {
-  if (exports.defaultInstance != null) {
-    exports.defaultInstance.kill();
+}
+
+function stop() {
+  if (defaultInstance != null)
+    defaultInstance.kill();
+  defaultInstance = null;
+}
+
+module.exports = {
+  path: crpath,
+  version,
+  start,
+  stop,
+  get defaultInstance() {
+    return defaultInstance;
   }
 };

programming_language: JavaScript
filename: package-lock.json
change_type: ModificationType.MODIFY
diff: @@ -1,12 +1,12 @@
 {
   "name": "chromedriver",
-  "version": "119.0.0",
+  "version": "119.0.1",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
     "": {
       "name": "chromedriver",
-      "version": "119.0.0",
+      "version": "119.0.1",
       "hasInstallScript": true,
       "license": "Apache-2.0",
       "dependencies": {

programming_language: JavaScript
filename: package.json
change_type: ModificationType.MODIFY
diff: @@ -1,6 +1,6 @@
 {
   "name": "chromedriver",
-  "version": "119.0.0",
+  "version": "119.0.1",
   "keywords": [
     "chromedriver",
     "selenium"

programming_language: JavaScript
filename: testStart.js
change_type: ModificationType.ADD
diff: @@ -0,0 +1,14 @@
+#!/usr/bin/env node
+
+"use strict";
+const chromedriver = require('./lib/chromedriver');
+
+async function run() {
+  console.log(`Starting chromedriver. Instance: ${JSON.stringify(chromedriver)}`);
+  await chromedriver.start(null, true);
+  console.log(`Started Chromedriver. Instance is null: ${chromedriver.defaultInstance === null}.`);
+  chromedriver.stop();
+  console.log(`Stopped Chromedriver. Instance is null: ${chromedriver.defaultInstance === null}.`);
+}
+
+run();

programming_language: TypeScript
filename: update.js
change_type: ModificationType.MODIFY
diff: @@ -21,14 +21,14 @@ async function getLatest() {
 }
 
 /* Provided a new Chromedriver version such as 77.0.3865.40:
-   - update the version inside the ./lib/chromedriver helper file e.g. exports.version = '77.0.3865.40';
+   - update the version inside the ./lib/chromedriver helper file e.g. const version = '77.0.3865.40';
    - bumps package.json version number
    - add a git tag using the new node-chromedriver version
    - add a git commit, e.g. Bump version to 77.0.0
 */
 async function writeUpdate(newVersion, shouldCommit) {
   const helper = fs.readFileSync('./lib/chromedriver.js', 'utf8');
-  const versionExport = 'exports.version';
+  const versionExport = 'const version';
   const regex = new RegExp(`^.*${versionExport}.*$`, 'gm');
   const updated = helper.replace(regex, `${versionExport} = '${newVersion}';`);
   const currentMajor = semver.major(currentVersionInPackageJson);

programming_language: JavaScript