[openssh-commits] [openssh] 02/13: upstream: check for expired/signal-deleted keys before processing

git+noreply at mindrot.org git+noreply at mindrot.org
Fri Nov 27 08:18:18 AEDT 2026


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit 5ac91c478380fe54ff1c7aded6490dbbf8987c23
Author: djm at openbsd.org <djm at openbsd.org>
AuthorDate: Thu Nov 26 05:42:21 2026 +0000

    upstream: check for expired/signal-deleted keys before processing
    
    each request rather than once per ppoll() round. Avoids keys being left
    available for use if multiple messages were read in one mainloop iteration.
    
    Anthropic ANT-2026-SHP0BXZS
    
    OpenBSD-Commit-ID: 45f47355cb3ada630b700d57c63cfe93dca4acaf
---
 ssh-agent.c | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/ssh-agent.c b/ssh-agent.c
index 3059069a2..fb8367357 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-agent.c,v 1.336 2026/10/30 07:18:18 djm Exp $ */
+/* $OpenBSD: ssh-agent.c,v 1.337 2026/11/26 05:42:21 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo at cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo at cs.hut.fi>, Espoo, Finland
@@ -1097,6 +1097,17 @@ process_remove_all_identities(SocketEntry *e)
 	send_status(e, 1);
 }
 
+/* removes all keys if a signal has asked for that */
+static void
+check_keydrop(void)
+{
+	if (!signalled_keydrop)
+		return;
+	logit("signal %d received; removing all keys", (int)signalled_keydrop);
+	remove_all_identities();
+	signalled_keydrop = 0;
+}
+
 /* removes expired keys and returns number of seconds until the next expiry */
 static time_t
 reaper(void)
@@ -1942,6 +1953,15 @@ process_message(u_int socknum)
 
 	debug_f("socket %u (fd=%d) type %d", socknum, e->fd, type);
 
+	/*
+	 * Requests served earlier in this pass of the main loop may have
+	 * taken a long time (e.g. slow signatures or confirmation dialogs).
+	 * Don't let this one use keys that have expired or that we were
+	 * told to drop in the meantime.
+	 */
+	check_keydrop();
+	(void) reaper();
+
 	/* check whether agent is locked */
 	if (locked && type != SSH_AGENTC_UNLOCK) {
 		switch (type) {
@@ -2711,12 +2731,7 @@ skip:
 			cleanup_exit((signalled_exit == SIGTERM &&
 			    socket_activated) ? 0 : 2);
 		}
-		if (signalled_keydrop) {
-			logit("signal %d received; removing all keys",
-			    (int)signalled_keydrop);
-			remove_all_identities();
-			signalled_keydrop = 0;
-		}
+		check_keydrop();
 		ptimeout_init(&timeout);
 		prepare_poll(&pfd, &npfd, &timeout, maxfds);
 		result = ppoll(pfd, npfd, ptimeout_get_tsp(&timeout), &osigset);

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list