vncviewer: prevent SSH option injection via -via gateway argument - #2131
Conversation
CendioOssman
left a comment
There was a problem hiding this comment.
Thanks. Good find!
The -via parameter is only available via the command line, though. Which makes this less of an issue.
Could you update the commit message to reflect that?
Isn't there a potential issue with remoteHost as well?
3177ac8 to
48ef50c
Compare
The -via command-line parameter is passed to ssh as a bare positional argument inside createTunnel()'s default command template. A value starting with "-" is parsed by ssh as an option rather than a hostname, so -via=-oProxyCommand=<cmd> causes ssh to run an arbitrary command through ProxyCommand. Shell quoting of "$G" only prevents shell metacharacter and word-splitting issues; it does not stop ssh from treating the value as an option. Insert "--" before the expanded gateway host so ssh stops parsing options at that point and treats the remainder strictly as the destination, closing the option-injection path.
|
Updated the commit message to clarify that I also checked |
|
Can't you trick it into splitting the |
|
I tested that payload. Since |
CendioOssman
left a comment
There was a problem hiding this comment.
Great. Thanks for checking!
The via parameter (from CLI, GUI, or a loaded .vnc config file) is
passed to ssh as a bare positional argument inside createTunnel()'s
default command template. A value starting with "-" is parsed by
ssh as an option rather than a hostname, so via=-oProxyCommand=
causes ssh to run an arbitrary command through ProxyCommand.
Shell quoting of "$G" only prevents shell metacharacter/word-splitting
issues, it does not stop ssh's own option parsing from treating the
value as an option.
This inserts "--" before the expanded gateway host so ssh stops
parsing options at that point and treats the remainder strictly as
the destination, closing off the option-injection path.
Tested by setting the via value to -oProxyCommand= and
confirming the command executes before the fix and is rejected
by ssh as an invalid hostname after the fix.