]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ssh-proxy: return an error if user supplies VMADDR_CID_ANY
authorNick Rosbrook <enr0n@ubuntu.com>
Fri, 20 Mar 2026 15:13:28 +0000 (11:13 -0400)
committerNick Rosbrook <enr0n@ubuntu.com>
Fri, 20 Mar 2026 15:37:31 +0000 (11:37 -0400)
Right now, if a user tries to pass VMADDR_CID_ANY to systemd-ssh-proxy,
an assert is triggered:

 $ ssh vsock%4294967295
 Assertion 'cid != VMADDR_CID_ANY' failed at src/ssh-generator/ssh-proxy.c:21, function process_vsock_cid(). Aborting.
 mm_receive_fd: recvmsg: expected received 1 got 0
 proxy dialer did not pass back a connection

This is becauase the value returned from vsock_parse_cid is not checked
before being passed to process_vsock_string. Add a check to prevent
that.

src/ssh-generator/ssh-proxy.c

index 337153787ec1d82dee1c21ab8fae70eb95d157d6..bfb91b5867c4eca23b1c3a58fcb45ca8bbc4b784 100644 (file)
@@ -62,6 +62,9 @@ static int process_vsock_string(const char *host, const char *port) {
         if (r < 0)
                 return log_error_errno(r, "Failed to parse vsock cid: %s", host);
 
+        if (cid == VMADDR_CID_ANY)
+                return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Cannot use VMADDR_CID_ANY to connect to a remote host.");
+
         return process_vsock_cid(cid, port);
 }