-
Notifications
You must be signed in to change notification settings - Fork 838
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix: Fix command injection vulnerability in grunt tzdata pipeline
The grunt data pipeline was constructed using full bash strings with input coming from command line, which can lead to arbitrary code execution. Switch from exec to execFile, which lists all command arguments in an array, so no injection is possible. Advisory: GHSA-56x4-j7p9-fcf9
- Loading branch information
Showing
3 changed files
with
20 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
"use strict"; | ||
|
||
var path = require('path'), | ||
exec = require('child_process').exec; | ||
execFile = require('child_process').execFile; | ||
|
||
module.exports = function (grunt) { | ||
grunt.registerTask('data-download', '1. Download data from iana.org/time-zones.', function (version) { | ||
version = version || 'latest'; | ||
|
||
var done = this.async(), | ||
src = 'ftp://ftp.iana.org/tz/tzdata-latest.tar.gz', | ||
src = (version === 'latest' ? | ||
'ftp://ftp.iana.org/tz/tzdata-latest.tar.gz' : | ||
'https://data.iana.org/time-zones/releases/tzdata' + version + '.tar.gz'), | ||
curl = path.resolve('temp/curl', version, 'data.tar.gz'), | ||
dest = path.resolve('temp/download', version); | ||
|
||
if (version !== 'latest') { | ||
src = 'https://data.iana.org/time-zones/releases/tzdata' + version + '.tar.gz'; | ||
} | ||
|
||
grunt.file.mkdir(path.dirname(curl)); | ||
grunt.file.mkdir(dest); | ||
|
||
grunt.log.ok('Downloading ' + src); | ||
|
||
exec('curl ' + src + ' -o ' + curl + ' && cd ' + dest + ' && gzip -dc ' + curl + ' | tar -xf -', function (err) { | ||
execFile('curl', [src, '-o', curl], function (err) { | ||
if (err) { throw err; } | ||
grunt.log.ok('Downloaded ' + curl + ', extracting . . .'); | ||
execFile('tar', ['-xzf', curl], { cwd: dest }, function (err) { | ||
if (err) { throw err; } | ||
|
||
grunt.log.ok('Downloaded ' + src); | ||
|
||
done(); | ||
grunt.log.ok('Extracted ' + dest); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters