CVE-2020-26245 (published 2020-11-27T20:15Z)

npm package systeminformation before version 4.30.5 is vulnerable to Prototype Pollution leading to Command Injection. The issue was fixed with a rewrite of shell sanitations to avoid prototyper pollution problems. The issue is fixed in version 4.30.5. If you cannot upgrade, be sure to check or sanitize service parameter strings that are passed to si.inetChecksite().

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-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/sebhildebrandt/systeminformation
commit_details: repo_url: https://github.com/sebhildebrandt/systeminformation
author: Sebastian Hildebrandt
author_date: 2020-11-26 18:15:15+01:00
msg: adapted security update (prototype pollution prevention)
repository: repo_url: https://github.com/sebhildebrandt/systeminformation
repo_name: sebhildebrandt/systeminformation
description: System Information Library for Node.JS
repo_language: JavaScript
owner: sebhildebrandt
file_changes: filename: CHANGELOG.md
change_type: ModificationType.MODIFY
diff: @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
 
 | Version        | Date           | Comment  |
 | -------------- | -------------- | -------- |
+| 4.30.5         | 2020-11-26     | adapted security update (prototype pollution prevention) |
 | 4.30.4         | 2020-11-25     | reverted Object.freeze because it broke some projects |
 | 4.30.3         | 2020-11-25     | security update (prototype pollution prevention) Object.freeze |
 | 4.30.2         | 2020-11-25     | security update (prototype pollution prevention) |

programming_language: Markdown
filename: history.html
change_type: ModificationType.MODIFY
diff: @@ -83,6 +83,11 @@
                   </tr>
                 </thead>
                 <tbody>
+                  <tr>
+                    <th scope="row">4.30.5</th>
+                    <td>2020-11-26</td>
+                    <td>adapted security update (prototype pollution prevention)</td>
+                  </tr>
                   <tr>
                     <th scope="row">4.30.4</th>
                     <td>2020-11-25</td>

programming_language: HTML
filename: index.html
change_type: ModificationType.MODIFY
diff: @@ -168,7 +168,7 @@
       <img class="logo" src="assets/logo.png">
       <div class="title">systeminformation</div>
       <div class="subtitle"><span id="typed"></span></div>
-      <div class="version">Current Version: <span id="version">4.30.4</span></div>
+      <div class="version">Current Version: <span id="version">4.30.5</span></div>
       <button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
     </div>
     <div class="down">

programming_language: HTML
filename: index.js
change_type: ModificationType.MODIFY
diff: @@ -21,9 +21,6 @@
 // Dependencies
 // ----------------------------------------------------------------------------------
 
-// Object.freeze(String.prototype);
-// Object.freeze(Object.prototype);
-
 const lib_version = require('../package.json').version;
 const util = require('./util');
 const system = require('./system');

programming_language: JavaScript
filename: internet.js
change_type: ModificationType.MODIFY
diff: @@ -40,6 +40,7 @@ function inetChecksite(url, callback) {
           s[i] === ' ' ||
           s[i] === '{' ||
           s[i] === '}')) {
+          s[i].__proto__.toLowerCase = util.stringToLower;
           const sl = s[i].toLowerCase();
           if (sl && sl[0] && !sl[1]) {
             urlSanitized = urlSanitized + sl[0];

programming_language: JavaScript
filename: network.js
change_type: ModificationType.MODIFY
diff: @@ -1040,8 +1040,13 @@ function networkStatsSingle(iface) {
 
   return new Promise((resolve) => {
     process.nextTick(() => {
-
-      const ifaceSanitized = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface);
+      let ifaceSanitized = '';
+      const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface);
+      for (let i = 0; i <= 2000; i++) {
+        if (!(s[i] === undefined)) {
+          ifaceSanitized = ifaceSanitized + s[i];
+        }
+      }
 
       let result = {
         iface: ifaceSanitized,

programming_language: TypeScript
filename: processes.js
change_type: ModificationType.MODIFY
diff: @@ -98,7 +98,18 @@ function services(srv, callback) {
   return new Promise((resolve) => {
     process.nextTick(() => {
       if (srv) {
-        let srvString = util.sanitizeShellString(srv);
+        let srvString = '';
+        srvString.__proto__.toLowerCase = util.stringToLower;
+        srvString.__proto__.replace = util.stringReplace;
+        srvString.__proto__.trim = util.stringTrim;
+
+        const s = util.sanitizeShellString(srv);
+        for (let i = 0; i <= 2000; i++) {
+          if (!(s[i] === undefined)) {
+            srvString = srvString + s[i];
+          }
+        }
+
         srvString = srvString.trim().toLowerCase().replace(/, /g, '|').replace(/,+/g, '|');
         if (srvString === '') {
           srvString = '*';

programming_language: JavaScript
filename: util.js
change_type: ModificationType.MODIFY
diff: @@ -48,6 +48,13 @@ function toInt(value) {
   return result;
 }
 
+
+const stringReplace = new String().replace;
+const stringToLower = new String().toLowerCase;
+const stringToString = new String().toString;
+const stringSubstr = new String().substr;
+const stringTrim = new String().trim;
+
 function isFunction(functionToCheck) {
   let getType = {};
   return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
@@ -523,6 +530,12 @@ function isPrototypePolluted() {
   const s = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
   let notPolluted = true;
   let st = '';
+
+  st.__proto__.replace = stringReplace;
+  st.__proto__.toLowerCase = stringToLower;
+  st.__proto__.toString = stringToString;
+  st.__proto__.substr = stringSubstr;
+
   notPolluted = notPolluted || !(s.length === 62)
   const ms = Date.now();
   if (typeof ms === 'number' && ms > 1600000000000) {
@@ -542,6 +555,7 @@ function isPrototypePolluted() {
     // string manipulation
     let p = Math.random() * l * 0.9999999999;
     let stm = st.substr(0, p) + ' ' + st.substr(p, 2000);
+    stm.__proto__.replace = stringReplace;
     let sto = stm.replace(/ /g, '');
     notPolluted = notPolluted && st === sto;
     p = Math.random() * l * 0.9999999999;
@@ -562,6 +576,7 @@ function isPrototypePolluted() {
     notPolluted = notPolluted && (stl.length === l) && stl[l - 1] && !(stl[l])
     for (let i = 0; i < l; i++) {
       const s1 = st[i];
+      s1.__proto__.toLowerCase = stringToLower;
       const s2 = stl ? stl[i] : '';
       const s1l = s1.toLowerCase();
       notPolluted = notPolluted && s1l[0] === s2 && s1l[0] && !(s1l[1]);
@@ -806,3 +821,8 @@ exports.isRaspbian = isRaspbian;
 exports.sanitizeShellString = sanitizeShellString;
 exports.isPrototypePolluted = isPrototypePolluted;
 exports.decodePiCpuinfo = decodePiCpuinfo;
+exports.stringReplace = stringReplace;
+exports.stringToLower = stringToLower;
+exports.stringToString = stringToString;
+exports.stringSubstr = stringSubstr;
+exports.stringTrim = stringTrim;

programming_language: JavaScript