This repository was archived by the owner on Dec 19, 2023. It is now read-only.
Fix Command Injection #3
Open
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 *
Bounty URL: https://www.huntr.dev/bounties/2-other-pirelenito/git-revision-webpack-plugin
⚙️ Description *
The
git-revision-webpack-pluginpackage is vulnerable toCommand Injectionvia commands concatenation.💻 Technical Description *
The file
run-git-command.jsdoes not sanitize the data provided by the user. So, any function in which uses this will be vulnerable.🐛 Proof of Concept (PoC) *
Exploring through
commithashfunction.The execution of the command above implies the creation of
poc.txtfile.🔥 Proof of Fix (PoF) *
The fix uses the
execFileofchild_processmodule to specify one single executable to be allowed, solving the problem with commands concatenation.As the entire command is put into a single string, it should be separated to
execFileworks correctly:execFile(executable, [arguments])Instead of applying the
splitfunction based on whitespace to get arguments of git commands, the fix uses a regex to solve the problems with commands in which have whitespaces between quotation marks, likegit "a b c".Thus, the execution of the PoC does not create the
poc.txtfile.👍 User Acceptance Testing (UAT)