This repository was archived by the owner on Dec 19, 2023. It is now read-only.
[CRITICAL] Fix command injection in library#1
Open
andreluis034 wants to merge 1 commit into418sec:masterfrom
andreluis034:master
Open
[CRITICAL] Fix command injection in library#1andreluis034 wants to merge 1 commit into418sec:masterfrom andreluis034:master
andreluis034 wants to merge 1 commit into418sec:masterfrom
andreluis034:master
Conversation
|
👋 Hello, @ralt - @andreluis034 has opened a PR to us with a fix for a potential vulnerability in your repository. To view the vulnerability, please refer to the bounty URL in the first comment, above. Ultimately, you get to decide if the fix is 👍 or 👎. If you are happy with the fix, please write a new comment ( If you have any questions or need support, come and join us on our community Discord! @ralt & @andreluis034 - thank you for your efforts in securing the world’s open source code! 🎉 |
huntr-helper
pushed a commit
to 418sec/huntr
that referenced
this pull request
Feb 6, 2021
This file contains hidden or 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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📊 Metadata *
Arbitrary code exec vulnerability
Bounty URL: https://www.huntr.dev/bounties/1-npm-docgenerator
⚙️ Description *
Docgenerator lets you write every chapter of your documentation in different markdown files, this library is vulnerable to a command injection attack.
💻 Technical Description *
This solution fixes the command injection in the library by utilizing
execFileinstead ofexecand by building the arguments in an array. Additionally the string that was vulnerable to command injection is passed directly tocreateWriteStreamwhich is not vulnerable to command injection and will throw an error if the file is not created.🐛 Proof of Concept (PoC) *
Steps To Reproduce
Sample Output
As you can see the malicious file bitcoinMiner.txt was introduced.
If a node project using this library takes the output parameter from untrusted input it will lead to remote code execution.
Remediation
Use the .spawn() directive.
🔥 Proof of Fix (PoF) *
Run the same PoC using this fix and no file will be created, an error will be printed that writing to the file failed.
👍 User Acceptance Testing (UAT)
This fix utilizes safer versions of invoking a process from node, it will not affect functionality.
🔗 Relates to...
418sec/huntr#1849