48 points · by twakefield · 6y ago · 49 comments
This doesn't even seem like a valid security concern. But I'm open to hearing about some ways that SCP would be vulnerable in ways that SFTP would not. I am by no means an expert in this subject.
We safely connect to evil machines all day long. That's what web browser sandboxes and BitTorrent are for.
We download files from evil machines and use checksums to verify the files.
Presumably by now scp is sufficiently tested not to have this bug. But this is precisely a defense against an evil server sending bad bytes.
The problem is that remote hosts, even ones you think you control, should be assumed potentially evil (compromised).
There's zero reason for a file transfer utility to support running arbitrary commands on the local machine at the remote host's command. That capability shouldn't exist in the protocol, full stop.
But since it does, if you're going to use scp regardless of what we know about it, there's clearly a broad spectrum of risk separating a random VPS in who knows what cloud running who knows what bits vs. the NAS machine in your closet that's only on a wired LAN behind a firewall running nothing that talks to the outside. Probably not the best choice to use scp to copy files to/from the former.
The amount of time I've saved when I've forgotten that I've done this and it just runs faster is well into the tens of hours. The amount of time I've lost when I forgot and rsync doesn't exist remotely is about 10 seconds total - enough time to read the error message -> `type -a scp` -> "oh yeah" -> use /usr/bin/scp instead.
Highly highly highly recommended.
place rogue SCP in /some/rogue/scp
export PATH=/some/rogue:$PATH
I often need to transfer very large binary files. When stuck with standard Linux tools, the fastest process is first transfer via scp. If the scp gets interrupted, resume it using rsync with the —-append-verify option.
mostly either:
rsync -av src dest
or: rsync -av --remove-source-files src destYou aren't necessarily wrong, but there's a whole world of distinction you're glossing over. Netcat is part of a set of tools you can use to construct a somewhat equivalent tool to scp without encryption, but nc by itself without tar and gzip (or whatever) match only the simplest possibly use case of scp, which is copying one file, without compression, and ignoring all permissions and ownership info.
This is also ignoring that you might not even have an open port on one side that the other can reach to have netcat listen on.
Tar may well be better if you know you need all the files and don't need the block checks per file to detect change and minimise data sent.
Rsync can hose the file buffer cache and slow a server down. If you want speed mbuffer is good but lacks channel security too (ZFS send over mbuffer is awesomely fast)
Err, what risks? If you run a server? Sure, but as a replacement for scp, where it's assumed you have an account on the remote system, an rsync server is not the equivalent solution, running rsync across an ssh connection is.
> Rsync over SSH is less risky but not risk free to either side. What is sent and what is asked for do not have to align well)
Glossing over that no system is "risk free", can you explain in a bit more detail here, or reference what you wrote up or some other thing? That's the kind of thing I would really want to know about, and an unsubstantiated throw-away aside does not do justice to the problem if accurate.
The proprietary ssh.com implementation of SSH apparently has one called "scp2", but I don't see any open source version.
Well, except for this, but it's tagged "[MAINTAINER WANTED]" and written in JavaScript:
Seems like a lot of effort when, In Theory, this would be a pretty straightforward wrapper to build on top of libssh, which can load OpenSSH's configuration files, or perhaps on top of OpenSSH's ssh/sftp binaries directly. But I'm too lazy to write one myself, so I was hoping someone already had :)
I think what is lacking is a precise split between file transfer and remote command execution.
If the split were well defined, we could simply and securely split out file transfer as a "thing".
it would allow:
- write-only no-account-required file uploads
- read-only no-account-required file downloads
- an account-required incoming dropbox
- an account-required file store
- full blown remote filesystems (filestore + file protocol goodies)
and a number of other services that involve files and NOT command execution, environment variables, shells, a login or even a user account.
Guess I maybe learned that wrong.