avoid the dashed ssh hostname class of security holes
Security fix: Disallow hostname starting with a dash, which would get passed to ssh and be treated an option. This could be used by an attacker who provides a crafted ssh url (for eg a git remote) to execute arbitrary code via ssh -oProxyCommand. No CVE has yet been assigned for this hole. The same class of security hole recently affected git itself, CVE-2017-1000117. Method: Identified all places where ssh is run, by git grep '"ssh"' Converted them all to use a SshHost, if they did not already, for specifying the hostname. SshHost was made a data type with a smart constructor, which rejects hostnames starting with '-'. Note that git-annex already contains extensive use of Utility.SafeCommand, which fixes a similar class of problem where a filename starting with a dash gets passed to a program which treats it as an option. This commit was sponsored by Jochen Bartl on Patreon.
This commit is contained in:
parent
25e55e7c2f
commit
df11e54788
12 changed files with 106 additions and 61 deletions
|
@ -19,13 +19,17 @@ import Remote.Helper.Messages
|
|||
import Messages.Progress
|
||||
import Utility.Metered
|
||||
import Utility.Rsync
|
||||
import Utility.SshHost
|
||||
import Types.Remote
|
||||
import Types.Transfer
|
||||
import Config
|
||||
|
||||
toRepo :: ConsumeStdin -> Git.Repo -> RemoteGitConfig -> SshCommand -> Annex (FilePath, [CommandParam])
|
||||
toRepo cs r gc remotecmd = do
|
||||
let host = fromMaybe (giveup "bad ssh url") $ Git.Url.hostuser r
|
||||
let host = maybe
|
||||
(giveup "bad ssh url")
|
||||
(either error id . mkSshHost)
|
||||
(Git.Url.hostuser r)
|
||||
sshCommand cs (host, Git.Url.port r) gc remotecmd
|
||||
|
||||
{- Generates parameters to run a git-annex-shell command on a remote
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue