Backport of:

From c805b97b67c774e0bf922ffb29dfbcda9d7b5add Mon Sep 17 00:00:00 2001
From: "djm@openbsd.org" <djm@openbsd.org>
Date: Thu, 2 Apr 2026 07:39:57 +0000
Subject: [PATCH] upstream: add missing askpass check when using

ControlMaster=ask/autoask and "ssh -O proxy ..."; reported by Michalis
Vasileiadis

OpenBSD-Commit-ID: 8dd7b9b96534e9a8726916b96d36bed466d3836a
---
 mux.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

--- a/mux.c
+++ b/mux.c
@@ -1122,6 +1122,16 @@ mux_master_process_proxy(struct ssh *ssh
 
 	debug_f("channel %d: proxy request", c->self);
 
+	if (options.control_master == SSHCTL_MASTER_ASK ||
+	    options.control_master == SSHCTL_MASTER_AUTO_ASK) {
+		if (!ask_permission("Allow multiplex proxy connection?")) {
+			debug2_f("proxy refused by user");
+			reply_error(reply, MUX_S_PERMISSION_DENIED, rid,
+			    "Permission denied");
+			return 0;
+		}
+	}
+
 	c->mux_rcb = channel_proxy_downstream;
 	if ((r = sshbuf_put_u32(reply, MUX_S_PROXY)) != 0 ||
 	    (r = sshbuf_put_u32(reply, rid)) != 0)
