Skip to content

Commit 8113ff0

Browse files
adapted security update (prototype pollution prevention)
1 parent 7b46935 commit 8113ff0

File tree

8 files changed

+47
-7
lines changed

8 files changed

+47
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
3030

3131
| Version | Date | Comment |
3232
| -------------- | -------------- | -------- |
33+
| 4.30.5 | 2020-11-26 | adapted security update (prototype pollution prevention) |
3334
| 4.30.4 | 2020-11-25 | reverted Object.freeze because it broke some projects |
3435
| 4.30.3 | 2020-11-25 | security update (prototype pollution prevention) Object.freeze |
3536
| 4.30.2 | 2020-11-25 | security update (prototype pollution prevention) |

docs/history.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ <h3>Full version history</h3>
8383
</tr>
8484
</thead>
8585
<tbody>
86+
<tr>
87+
<th scope="row">4.30.5</th>
88+
<td>2020-11-26</td>
89+
<td>adapted security update (prototype pollution prevention)</td>
90+
</tr>
8691
<tr>
8792
<th scope="row">4.30.4</th>
8893
<td>2020-11-25</td>

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
<img class="logo" src="assets/logo.png">
169169
<div class="title">systeminformation</div>
170170
<div class="subtitle"><span id="typed"></span></div>
171-
<div class="version">Current Version: <span id="version">4.30.4</span></div>
171+
<div class="version">Current Version: <span id="version">4.30.5</span></div>
172172
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
173173
</div>
174174
<div class="down">

lib/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
// Dependencies
2222
// ----------------------------------------------------------------------------------
2323

24-
// Object.freeze(String.prototype);
25-
// Object.freeze(Object.prototype);
26-
2724
const lib_version = require('../package.json').version;
2825
const util = require('./util');
2926
const system = require('./system');

lib/internet.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function inetChecksite(url, callback) {
4040
s[i] === ' ' ||
4141
s[i] === '{' ||
4242
s[i] === '}')) {
43+
s[i].__proto__.toLowerCase = util.stringToLower;
4344
const sl = s[i].toLowerCase();
4445
if (sl && sl[0] && !sl[1]) {
4546
urlSanitized = urlSanitized + sl[0];

lib/network.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,8 +1040,13 @@ function networkStatsSingle(iface) {
10401040

10411041
return new Promise((resolve) => {
10421042
process.nextTick(() => {
1043-
1044-
const ifaceSanitized = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface);
1043+
let ifaceSanitized = '';
1044+
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface);
1045+
for (let i = 0; i <= 2000; i++) {
1046+
if (!(s[i] === undefined)) {
1047+
ifaceSanitized = ifaceSanitized + s[i];
1048+
}
1049+
}
10451050

10461051
let result = {
10471052
iface: ifaceSanitized,

lib/processes.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,18 @@ function services(srv, callback) {
9898
return new Promise((resolve) => {
9999
process.nextTick(() => {
100100
if (srv) {
101-
let srvString = util.sanitizeShellString(srv);
101+
let srvString = '';
102+
srvString.__proto__.toLowerCase = util.stringToLower;
103+
srvString.__proto__.replace = util.stringReplace;
104+
srvString.__proto__.trim = util.stringTrim;
105+
106+
const s = util.sanitizeShellString(srv);
107+
for (let i = 0; i <= 2000; i++) {
108+
if (!(s[i] === undefined)) {
109+
srvString = srvString + s[i];
110+
}
111+
}
112+
102113
srvString = srvString.trim().toLowerCase().replace(/, /g, '|').replace(/,+/g, '|');
103114
if (srvString === '') {
104115
srvString = '*';

lib/util.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ function toInt(value) {
4848
return result;
4949
}
5050

51+
52+
const stringReplace = new String().replace;
53+
const stringToLower = new String().toLowerCase;
54+
const stringToString = new String().toString;
55+
const stringSubstr = new String().substr;
56+
const stringTrim = new String().trim;
57+
5158
function isFunction(functionToCheck) {
5259
let getType = {};
5360
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
@@ -523,6 +530,12 @@ function isPrototypePolluted() {
523530
const s = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
524531
let notPolluted = true;
525532
let st = '';
533+
534+
st.__proto__.replace = stringReplace;
535+
st.__proto__.toLowerCase = stringToLower;
536+
st.__proto__.toString = stringToString;
537+
st.__proto__.substr = stringSubstr;
538+
526539
notPolluted = notPolluted || !(s.length === 62)
527540
const ms = Date.now();
528541
if (typeof ms === 'number' && ms > 1600000000000) {
@@ -542,6 +555,7 @@ function isPrototypePolluted() {
542555
// string manipulation
543556
let p = Math.random() * l * 0.9999999999;
544557
let stm = st.substr(0, p) + ' ' + st.substr(p, 2000);
558+
stm.__proto__.replace = stringReplace;
545559
let sto = stm.replace(/ /g, '');
546560
notPolluted = notPolluted && st === sto;
547561
p = Math.random() * l * 0.9999999999;
@@ -562,6 +576,7 @@ function isPrototypePolluted() {
562576
notPolluted = notPolluted && (stl.length === l) && stl[l - 1] && !(stl[l])
563577
for (let i = 0; i < l; i++) {
564578
const s1 = st[i];
579+
s1.__proto__.toLowerCase = stringToLower;
565580
const s2 = stl ? stl[i] : '';
566581
const s1l = s1.toLowerCase();
567582
notPolluted = notPolluted && s1l[0] === s2 && s1l[0] && !(s1l[1]);
@@ -806,3 +821,8 @@ exports.isRaspbian = isRaspbian;
806821
exports.sanitizeShellString = sanitizeShellString;
807822
exports.isPrototypePolluted = isPrototypePolluted;
808823
exports.decodePiCpuinfo = decodePiCpuinfo;
824+
exports.stringReplace = stringReplace;
825+
exports.stringToLower = stringToLower;
826+
exports.stringToString = stringToString;
827+
exports.stringSubstr = stringSubstr;
828+
exports.stringTrim = stringTrim;

0 commit comments

Comments
 (0)