Calling into sed when you use ssh increases your attack surface to include sed's attack surface. And likely more.
If you're being paranoid, you can also break this like: ssh -v 'foo;bar.bast'
Still, the only way I see this being any kind of "attack surface" is if an attacker could control the hostname you're connecting to, and I'll bet there are much naughtier thing possible in that case.
$ ssh localhost -o ProxyCommand="ssh localhost 'pstree -a \$PPID >&2 ; nc %h %p'"
sshd
`-bash -c pstree -a $PPID >&2 ; nc localhost 22
`-pstree -a 6703
Bash invoked this way will be non-interactive. Often bashrc will test "$PS1" to bail early in this case, but the point remains that it does run. I also tried my command with echos before and after that test in my bashrc to confirm what happens.It will never touch any part of the network, or handle any untrusted input. So this is not a concern.