-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes arbitrary command injection by using execFile instead of exec #18
Conversation
@Logikgate Do you intend to fix the CI errors? It's failing for Node 0.8, 0.9 and 0.10. |
@jourdanrodrigues sorry, yes just pushed up the fix. I also modified the .travis.yml to test against both macos and linux |
@Logikgate Thanks! And sorry for not expressing myself well. Now that I'm reading my comment, it sounds rude. |
@jourdanrodrigues no problem! I hadn't noticed the failed build so I appreciate the nudge :) @scravy Could you take a look at this and if everything looks good release a new version? A lot of packages depend on macaddress and they are all failing snyk and nsp checks. This would also close out issue #19 as well as #9 & #7 since those are just requesting a new release. |
(Pretend I've written some witty "get off my lawn" "I hate nodejs on principle" rant, even though I'm much too young for that.) It's incredibly wasteful to invoke a subprocess just to cat a file, this module deserves a Useless Use of Cat award as well as the vulnerability. "but it's so easy to code" ==> but invoking subprocesses to cat a file causes people to get confused about whether they are using a shell or not, and maybe end up introducing the glaring security hole mentioned here.
Why, whenever people write code in powerful programming languages (unlike shell), do they always obsessively somehow end up running vastly weaker, more dangerously misused/abused/vulnerable shell commands (or even direct execution with argv in a list, which is only maybe a little bit barely safer), in order to get inferior results??? ... Sorry, this is not your fault, you're just trying to fix it and I get that, but I really think it's useful to just rethink the whole paradigm here. The language should be used the way it was intended, not abused for cheap shell hacks. Don't use subprocesses unless there's no other choice. |
@eli-schwartz I don't disagree at all with what you said and yes I was only trying to fix the issue at hand not rethink how this project is doing things. Your example of how to get the same information that cat does make sense, but I can't, of the top of my head, think of how to get around the execution of ifconfig and ipconfig that the unix and windows implementations use. Can you? |
You even get informative error messages like:
On the topic of Windows/Unix compat, I don't know how you'd go about collecting the information in general. Python has a simple ctypes builtin functionfor this ( In-process is "nicer", and comes with benefits like not relying on regular expression parsing of tools without a guaranteed scriptable output format (!!!), but if you absolutely have to run some external command via subprocesses, at least do it with full awareness it is being done as a last resort. |
@eli-schwartz Please open up a separate PR to remove the use of |
The best way to do this for Windows is to probably use a native module (C++ addon) and the GetAdaptersInfo MFC function. But I think fixing the vulnerability is the much more important issue at hand; which this pull request does. The Thanks to everyone that worked on this. I don't use this package directly, but its existence enables my stuff to work. 👍 |
how do i 'npm install' this pull request over the node-macaddress dependency? |
I am closing this PR since I accidentally opened it on the master branch of our fork. Please reference the newly opened PR #20 |
execFile takes the call arguments as variables and they are not executed under the shell environment
Reference
https://blog.liftsecurity.io/2014/08/19/Avoid-Command-Injection-Node.js/