Git LFS may attempt arbitrary remote commands via crafted SSH URLs
Description
Impact
When Git LFS makes object transfer or authentication requests to a remote host via SSH, it passes the path component of the remote's SSH URL as part of a command to be executed, but does not properly format the URL's path component as a single argument. By inserting shell meta-characters into the SSH URL, an attacker may be able to execute arbitrary commands on the remote host, if the host passes the commands to a shell without sanitizing them first.
Git LFS has resolved this problem by fully quoting the arguments of the remote commands it sends via SSH.
As well, Git LFS has resolved a problem with the default HTTPS URLs used when an SSH URL is configured for a remote host and the host either does not support Git LFS remote commands sent via SSH or supports HTTP authentication via SSH for Git LFS but does not return an explicit HTTP URL in response to a git-lfs-authenticate remote command. In these cases, Git LFS now correctly encodes the HTTPS URL used to contact the remote host.
Patches
This problem exists in all versions since 0.5.0 and is patched in v3.8.1. All users should upgrade to v3.8.1.
Workarounds
Users may set the lfs.sshTransfer Git configuration option to never, after which Git LFS will not attempt any object transfers over SSH. However, Git LFS will still make authentication requests to SSH URLs, so administrators of Git LFS services should ensure their systems sanitize all commands received over SSH before executing them.