Skip to content

Commit 7fe7e94

Browse files
committed
Mitigate CVE-2023-23596 by changing child_process.exec to child_process.execFile
1 parent fd30cfe commit 7fe7e94

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

backend/internal/access-list.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ const internalAccessList = {
507507
if (typeof item.password !== 'undefined' && item.password.length) {
508508
logger.info('Adding: ' + item.username);
509509

510-
utils.exec('/usr/bin/htpasswd -b "' + htpasswd_file + '" "' + item.username + '" "' + item.password + '"')
510+
utils.execFile('/usr/bin/htpasswd',['-b', htpasswd_file, item.username, item.password])
511511
.then((/*result*/) => {
512512
next();
513513
})

backend/lib/utils.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const exec = require('child_process').exec;
2+
const execFile = require('child_process').execFile;
23

34
module.exports = {
45

@@ -16,5 +17,21 @@ module.exports = {
1617
}
1718
});
1819
});
20+
},
21+
22+
/**
23+
* @param {Array} cmd
24+
* @returns {Promise}
25+
*/
26+
execFile: function (cmd) {
27+
return new Promise((resolve, reject) => {
28+
execFile(cmd, function (err, stdout, /*stderr*/) {
29+
if (err && typeof err === 'object') {
30+
reject(err);
31+
} else {
32+
resolve(stdout.trim());
33+
}
34+
});
35+
});
1936
}
2037
};

0 commit comments

Comments
 (0)