[openssh-commits] [openssh] 07/18: upstream: avoid weird tab-completion spoofing by a hostile server

git+noreply at mindrot.org git+noreply at mindrot.org
Wed Nov 25 19:56:02 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 2be74edcd3cd270ba48599784e247134e360fab3
Author: djm at openbsd.org <djm at openbsd.org>
AuthorDate: Wed Nov 25 07:11:03 2026 +0000

    upstream: avoid weird tab-completion spoofing by a hostile server
    
    by escaping all characters in paths that have special meaning.
    
    Anthropic ANT-2026-8668SJFV
    
    OpenBSD-Commit-ID: 182aa62b9da4f3ac4c2c0c8c2797407b8f4d1579
---
 sftp.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/sftp.c b/sftp.c
index 2c03316c5..c9e8fb746 100644
--- a/sftp.c
+++ b/sftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp.c,v 1.264 2026/11/02 12:55:33 jsg Exp $ */
+/* $OpenBSD: sftp.c,v 1.265 2026/11/25 07:11:03 djm Exp $ */
 /*
  * Copyright (c) 2001-2004 Damien Miller <djm at openbsd.org>
  *
@@ -2161,16 +2161,28 @@ complete_match(EditLine *el, struct sftp_conn *conn, char *remote_path,
 			ins[0] = '\\';
 			memcpy(ins + 1, tmp2 + i, clen);
 			ins[clen + 1] = '\0';
+			/*
+			 * Escape everything that makeargv() or glob(3) treat
+			 * specially: quotes, backslash, all isspace() chars,
+			 * comment and glob characters. Within a quoted
+			 * argument only the quote and backslash need it.
+			 */
 			switch (tmp2[i]) {
 			case '\'':
 			case '"':
 			case '\\':
 			case '\t':
+			case '\n':
+			case '\v':
+			case '\f':
+			case '\r':
 			case '[':
 			case ' ':
 			case '#':
 			case '*':
-				if (quote == '\0' || tmp2[i] == quote) {
+			case '?':
+				if (quote == '\0' || tmp2[i] == quote ||
+				    tmp2[i] == '\\') {
 					if (el_insertstr(el, ins) == -1)
 						fatal("el_insertstr "
 						    "failed.");

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


More information about the openssh-commits mailing list