News for hackers. Stuff that matters.
Re:Building Interactive SSH Applications by megous on Monday September 02, 2019 @07:19AM (#20858372)
Possibly a lot of shell command interpolation going on there.

What if I try to login as "bob'; rm -rf /" or some such? Is the system robust against that?

Re:Building Interactive SSH Applications by chousuke on Monday September 02, 2019 @09:12AM (#20858904)
The only point I see for injection is when OpenSSH runs the AuthorizedKeysCommand. I'm pretty sure OpenSSH handles it fine.
Re:Building Interactive SSH Applications by megous on Monday September 02, 2019 @12:54PM (#20860320)
Then look at the code. You may be surprised.

Looking at the escaping function, it will allow $(execute whatever you want), because it doesn't handle $.

https://github.com/openssh/openssh-portable/blob/master/misc...

Anyway, this depends on being able to specify any username, which while possible, requires you to pass the check that user exists in the system, which will be harder.

But it may still be possible if some weird PAM module is used.

Re:Building Interactive SSH Applications by mbrock on Monday September 02, 2019 @01:36PM (#20860620)
I don't think that function is used other than for logging.

https://github.com/openssh/openssh-portable/blob/b52c0c2e649...

There the "command" variable is the result of the function you mention, but here the use is only for logging. The actual argv for the subprocess is the "av" argument which comes from first splitting and then replacing "%u" etc.

Re:Building Interactive SSH Applications by megous on Monday September 02, 2019 @01:45PM (#20860676)
I see. Good.
Re:Building Interactive SSH Applications by megous on Monday September 02, 2019 @12:58PM (#20860344)
Changing this to use ' instead of " may fix this issue.

https://github.com/openssh/openssh-portable/blob/master/misc...

Because then you'll end up with '$(some)' instead of "$(some)"

Re:Building Interactive SSH Applications by smhenderson on Monday September 02, 2019 @08:46AM (#20858744)
Does bob have proper permissions to delete root? Probably not...

But otherwise, yes, you can run any valid command or pipeline on the server side so rm -rf is certainly acceptable.

Re:Building Interactive SSH Applications by megous on Monday September 02, 2019 @01:04PM (#20860401)
Bob does not, but the AuthorizedKeysCommand runs as:

    AuthorizedKeysCommandUser root
I'm pretty sure that is enough permissions to cause trouble.
Re:Building Interactive SSH Applications by smhenderson on Monday September 02, 2019 @01:15PM (#20860477)
I confess I read the article after my comment and saw that.

I was just talking about standard ssh behavior.

I wouldn’t use that without seriously studying it end to end. As another comment said, “seems kind of hacky”.

Re:Building Interactive SSH Applications by Nextgrid on Monday September 02, 2019 @08:49AM (#20858768)
Yeah it is a bit concerning to be honest, feels hacky.
Re:Building Interactive SSH Applications by mbrock on Monday September 02, 2019 @09:03AM (#20858854)
Where do you see the problematic interpolation?
Re:Building Interactive SSH Applications by targonca on Monday September 02, 2019 @09:45AM (#20859068)

    keys = (f"command=\"buildsrht-shell '{b64key}'\",restrict,pty " +
            f"{key_type} {b64key} somebody\n")
Now it depends on how b64key is sanitized.
Re:Building Interactive SSH Applications by megous on Monday September 02, 2019 @01:05PM (#20860407)
AuthorizedKeysCommand, see above