summaryrefslogtreecommitdiff
path: root/Remote/GCrypt.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-08-17 22:11:31 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-08-17 22:11:31 -0400
commitc1aec2ae837c24b602c7a0ca3fc7b0fcad565758 (patch)
tree6ce58560d65d4a3a6529569cfdde4c80b6b5e5bf /Remote/GCrypt.hs
parentd998fce1481a4bc7779e21cb2ff6a0fa42d72c7a (diff)
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.
Diffstat (limited to 'Remote/GCrypt.hs')
-rw-r--r--Remote/GCrypt.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/Remote/GCrypt.hs b/Remote/GCrypt.hs
index ee949ea08..2ccc47ad8 100644
--- a/Remote/GCrypt.hs
+++ b/Remote/GCrypt.hs
@@ -48,6 +48,7 @@ import Utility.Rsync
import Utility.Tmp
import Logs.Remote
import Utility.Gpg
+import Utility.SshHost
remote :: RemoteType
remote = RemoteType {
@@ -158,8 +159,9 @@ rsyncTransport r gc
let rsyncpath = if "/~/" `isPrefixOf` path
then drop 3 path
else path
- opts <- sshOptions ConsumeStdin (host, Nothing) gc []
- return (rsyncShell $ Param "ssh" : opts, host ++ ":" ++ rsyncpath, AccessShell)
+ let sshhost = either error id (mkSshHost host)
+ opts <- sshOptions ConsumeStdin (sshhost, Nothing) gc []
+ return (rsyncShell $ Param "ssh" : opts, fromSshHost sshhost ++ ":" ++ rsyncpath, AccessShell)
othertransport = return ([], loc, AccessDirect)
noCrypto :: Annex a