forked from scravy/node-macaddress
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix arbitrary command injection, CWE-264
- Loading branch information
Showing
4 changed files
with
9 additions
and
9 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,11 +1,11 @@ | ||
var exec = require('child_process').exec; | ||
var execFile = require('child_process').execFile; | ||
|
||
module.exports = function (iface, callback) { | ||
exec("cat /sys/class/net/" + iface + "/address", function (err, out) { | ||
execFile("cat", ["/sys/class/net/", iface, "/address"], function (err, out) { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
if (err) { | ||
callback(err, null); | ||
return; | ||
} | ||
callback(null, out.trim().toLowerCase()); | ||
}); | ||
}; | ||
}; |
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
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
There's a fs#readFile for reading files, you don't need to use
cat
andexec*
functions for that.Besides that, I'd use path#basename on
iface
as well to avoid path traversal (even though I doubt that anyone would really use file namedaddress
in production, but you'll never know 😉)