Skip to content

Commit

Permalink
patch: fixes possible injection issue for notify-send
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelbr committed Mar 11, 2021
1 parent 1101e6d commit c4b8ade
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/utils.js
Expand Up @@ -285,7 +285,9 @@ module.exports.constructArgumentList = function(options, extra) {
};

initial.forEach(function(val) {
args.push(escapeFn(val));
if (typeof val === 'string') {
args.push(escapeFn(val));
}
});
for (var key in options) {
if (
Expand Down
11 changes: 11 additions & 0 deletions test/notify-send.js
Expand Up @@ -71,6 +71,17 @@ describe('notify-send', function() {
notifier.notify({ title: 'title', message: 'body', icon: 'icon-string' });
});

it('should only include strings as arguments', function(done) {
var expected = ['"HACKED"'];

expectArgsListToBe(expected, done);
var notifier = new Notify({ suppressOsdCheck: true });
var options = JSON.parse(
'{"title":"HACKED", "message":["`touch HACKED`"]}'
);
notifier.notify(options);
});

it('should remove extra options that are not supported by notify-send', function(done) {
var expected = [
'"title"',
Expand Down

0 comments on commit c4b8ade

Please sign in to comment.