Security
What lnk exit start --on <machine> exposes, and what it doesn't. How an
agent's traffic reaches the exit, through Link's filtering proxy, is in
the sandbox's
security.
It needs no administrator rights here or on the machine.
What's reachable
What the exit connects, what it reaches, and who on the machine can use it.
The forward
The exit is an ssh -R from here to the machine, over Link's SSH to a
box (--on, lnk box forward) or your own SSH setup for any other
host, to a SOCKS5 server on this computer's loopback, at a free port,
while the exit is up (lnk exit socks, the exit plugin's own).
What the server reaches
Only the internet: never this computer's own addresses or loopback, its LAN, link-local or shared (CGNAT) ranges, a cloud's metadata service, the IPv6 /48 around this computer's own address, where the other devices of its network are, or its network's public IPv4 address, where some routers answer their admin page from inside.
Addresses, never names
It takes addresses only and never resolves a name, so a name can't point it home. A program on the machine gets your home address, not your home.
The socket on the machine
On the machine, the SOCKS5 proxy is a Unix socket in your home folder,
~/.lnk/exit/exit.sock, which sshd makes readable and writable by your
user only (StreamLocalBindMask, 0177 by default), in a folder only
yours (700). Your programs on that machine can use it; other users
there and nothing on its network can.
Why that's the lock
The proxy takes no password, so this is what keeps others out. No sshd
setting opens a socket to the network, as GatewayPorts does a port.
On each connection
The exit first removes a socket a connection before left there (sshd
leaves it, and binds over none), then asks for the forward to it over
that same connection. For a host reached with ssh, that's ssh's shared
connection, its control socket in ~/.lnk/exit/ on this computer, only
yours. So of two computers making one machine their exit, the one that
connected last has the socket.
An exit that runs otherwise
The next lnk exit start --on <machine> restarts any exit whose service
differs from what this lnk would start, one running ssh's own SOCKS,
which reaches this computer and its LAN, among them; lnk agent move
and lnk agent exit --here run it.
An agent on the box
An agent's proxy on a box reaches the socket by its path; the agent
itself can't: every sandbox hides the machine folder, ~/.lnk, the
socket's folder in it (making it when it's missing, so a socket put
there later never shows in a running sandbox).
How it learns your public address
When the exit starts, and every 5 minutes, it asks your router with
NAT-PMP, and Cloudflare's STUN server (stun.cloudflare.com) which
address your connections are seen from. Cloudflare sees a request from
your address and nothing else. It refuses both, and keeps the last ones
learned when neither answers.
Who can use your address
Any program of your user on that machine can use your home address while the exit is up, not only your agent. Make a machine your exit only if what runs there is yours.
When this computer is off
With this computer off or offline, or the SSH connection down, nothing answers on the socket, or the port, and nothing gets home. An agent routed through the exit then has no internet at all: it fails closed and never falls back to the machine's own network.
Limits
What the exit can't do, or needs of a machine.
Addresses it can't know
Your network's public IPv4 address is refused only once learned: with no NAT-PMP on your router and no UDP out to STUN, it isn't. IPv6 devices of your network outside the /48 around this computer's address aren't known to it.
TCP, through a proxy
TCP only, through a SOCKS5 proxy: a program has to use it, and give it addresses, not names, since the proxy never resolves one.
What a host needs
For a host that isn't a box, SSH runs with BatchMode=yes, so it must
work without typing anything, and the host needs /bin/sh.
Paths and names
The socket's path, home folder included, must fit a Unix socket's (about
100 characters), and the home folder's path is letters, digits and
/._-+@ only; otherwise the exit can't start on the socket. A machine's name is letters, digits and @._:- only, and
never starts with -, so it can't be read as an SSH option.