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

Curling Directly into Bash is Insecure #1190

Open
Snuggle opened this issue Sep 22, 2018 · 0 comments
Open

Curling Directly into Bash is Insecure #1190

Snuggle opened this issue Sep 22, 2018 · 0 comments

Comments

@Snuggle
Copy link

Snuggle commented Sep 22, 2018

Description

The current installation method can be exploited to cause arbitrary code to be executed on the client machine due to a timing difference between piping directly into bash and into stdout or another file. The user would be unable to detect such a malicious payload through conventional means.

I've noticed that your installer is based on a Chef tutorial. I've made a similar issue on their GitHub too.

image
Gif of exploit - Note different payloads depending on if it is output to bash or stdout:

Please read the following article to see how this exploit works:
https://www.idontplaydarts.com/2016/04/detecting-curl-pipe-bash-server-side/

How can this be fixed?

The following command is insecure:
curl https://getmic.ro | bash

This is because the server for https://getmic.ro can watch and delay the connection speed incredibly carefully and detect if the client is curling directly into bash, or if it is being output to stdout/into a file.

The consequences of this timing difference mean it's possible to send entirely different payloads for each scenario, evading detection from anyone who decides to look for the contents by outputting the downloaded data.
image

The way to fix this command:
The getmic.ro script needs to be output into a file before the user executes it. Otherwise different payloads can be used without any way for the user to verify what they're executing.

The following commands fix the security issue, but aren't as pretty and short. You might be able to improve upon this.

Any of the following will work instead and be more secure:
curl https://getmic.ro > GetMicro; bash GetMicro
curl -o GetMicro https://getmic.ro; bash GetMicro
wget https://getmic.ro; bash index.html
wget https://getmic.ro/install; bash install # This one will require a server-side change.

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

No branches or pull requests

1 participant