diff options
| -rw-r--r-- | meta/recipes-connectivity/openssh/openssh/CVE-2023-51385.patch | 97 | ||||
| -rw-r--r-- | meta/recipes-connectivity/openssh/openssh_8.9p1.bb | 1 |
2 files changed, 98 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/openssh/openssh/CVE-2023-51385.patch b/meta/recipes-connectivity/openssh/openssh/CVE-2023-51385.patch new file mode 100644 index 0000000000..b8e6813857 --- /dev/null +++ b/meta/recipes-connectivity/openssh/openssh/CVE-2023-51385.patch | |||
| @@ -0,0 +1,97 @@ | |||
| 1 | From 7ef3787c84b6b524501211b11a26c742f829af1a Mon Sep 17 00:00:00 2001 | ||
| 2 | From: "djm@openbsd.org" <djm@openbsd.org> | ||
| 3 | Date: Mon, 18 Dec 2023 14:47:44 +0000 | ||
| 4 | Subject: [PATCH] upstream: ban user/hostnames with most shell metacharacters | ||
| 5 | This makes ssh(1) refuse user or host names provided on the commandline that | ||
| 6 | contain most shell metacharacters. | ||
| 7 | |||
| 8 | Some programs that invoke ssh(1) using untrusted data do not filter | ||
| 9 | metacharacters in arguments they supply. This could create | ||
| 10 | interactions with user-specified ProxyCommand and other directives | ||
| 11 | that allow shell injection attacks to occur. | ||
| 12 | |||
| 13 | It's a mistake to invoke ssh(1) with arbitrary untrusted arguments, | ||
| 14 | but getting this stuff right can be tricky, so this should prevent | ||
| 15 | most obvious ways of creating risky situations. It however is not | ||
| 16 | and cannot be perfect: ssh(1) has no practical way of interpreting | ||
| 17 | what shell quoting rules are in use and how they interact with the | ||
| 18 | user's specified ProxyCommand. | ||
| 19 | |||
| 20 | To allow configurations that use strange user or hostnames to | ||
| 21 | continue to work, this strictness is applied only to names coming | ||
| 22 | from the commandline. Names specified using User or Hostname | ||
| 23 | directives in ssh_config(5) are not affected. | ||
| 24 | |||
| 25 | feedback/ok millert@ markus@ dtucker@ deraadt@ | ||
| 26 | |||
| 27 | OpenBSD-Commit-ID: 3b487348b5964f3e77b6b4d3da4c3b439e94b2d9 | ||
| 28 | |||
| 29 | CVE: CVE-2023-51385 | ||
| 30 | |||
| 31 | Upstream-Status: Backport | ||
| 32 | [https://github.com/openssh/openssh-portable/commit/7ef3787c84b6b524501211b11a26c742f829af1a] | ||
| 33 | |||
| 34 | Signed-off-by: Archana Polampalli <archana.polampalli@windriver.com> | ||
| 35 | --- | ||
| 36 | ssh.c | 39 +++++++++++++++++++++++++++++++++++++++ | ||
| 37 | 1 file changed, 39 insertions(+) | ||
| 38 | |||
| 39 | diff --git a/ssh.c b/ssh.c | ||
| 40 | index 8ff9788..82ed15f 100644 | ||
| 41 | --- a/ssh.c | ||
| 42 | +++ b/ssh.c | ||
| 43 | @@ -611,6 +611,41 @@ ssh_conn_info_free(struct ssh_conn_info *cinfo) | ||
| 44 | free(cinfo); | ||
| 45 | } | ||
| 46 | |||
| 47 | +static int | ||
| 48 | +valid_hostname(const char *s) | ||
| 49 | +{ | ||
| 50 | + size_t i; | ||
| 51 | + | ||
| 52 | + if (*s == '-') | ||
| 53 | + return 0; | ||
| 54 | + for (i = 0; s[i] != 0; i++) { | ||
| 55 | + if (strchr("'`\"$\\;&<>|(){}", s[i]) != NULL || | ||
| 56 | + isspace((u_char)s[i]) || iscntrl((u_char)s[i])) | ||
| 57 | + return 0; | ||
| 58 | + } | ||
| 59 | + return 1; | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | +static int | ||
| 63 | +valid_ruser(const char *s) | ||
| 64 | +{ | ||
| 65 | + size_t i; | ||
| 66 | + | ||
| 67 | + if (*s == '-') | ||
| 68 | + return 0; | ||
| 69 | + for (i = 0; s[i] != 0; i++) { | ||
| 70 | + if (strchr("'`\";&<>|(){}", s[i]) != NULL) | ||
| 71 | + return 0; | ||
| 72 | + /* Disallow '-' after whitespace */ | ||
| 73 | + if (isspace((u_char)s[i]) && s[i + 1] == '-') | ||
| 74 | + return 0; | ||
| 75 | + /* Disallow \ in last position */ | ||
| 76 | + if (s[i] == '\\' && s[i + 1] == '\0') | ||
| 77 | + return 0; | ||
| 78 | + } | ||
| 79 | + return 1; | ||
| 80 | +} | ||
| 81 | + | ||
| 82 | /* | ||
| 83 | * Main program for the ssh client. | ||
| 84 | */ | ||
| 85 | @@ -1097,6 +1132,10 @@ main(int ac, char **av) | ||
| 86 | if (!host) | ||
| 87 | usage(); | ||
| 88 | |||
| 89 | + if (!valid_hostname(host)) | ||
| 90 | + fatal("hostname contains invalid characters"); | ||
| 91 | + if (options.user != NULL && !valid_ruser(options.user)) | ||
| 92 | + fatal("remote username contains invalid characters"); | ||
| 93 | host_arg = xstrdup(host); | ||
| 94 | |||
| 95 | /* Initialize the command to execute on remote host. */ | ||
| 96 | -- | ||
| 97 | 2.40.0 | ||
diff --git a/meta/recipes-connectivity/openssh/openssh_8.9p1.bb b/meta/recipes-connectivity/openssh/openssh_8.9p1.bb index 3860899540..bc8e2d81b8 100644 --- a/meta/recipes-connectivity/openssh/openssh_8.9p1.bb +++ b/meta/recipes-connectivity/openssh/openssh_8.9p1.bb | |||
| @@ -35,6 +35,7 @@ SRC_URI = "http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-${PV}.tar | |||
| 35 | file://fix-authorized-principals-command.patch \ | 35 | file://fix-authorized-principals-command.patch \ |
| 36 | file://CVE-2023-48795.patch \ | 36 | file://CVE-2023-48795.patch \ |
| 37 | file://CVE-2023-51384.patch \ | 37 | file://CVE-2023-51384.patch \ |
| 38 | file://CVE-2023-51385.patch \ | ||
| 38 | " | 39 | " |
| 39 | SRC_URI[sha256sum] = "fd497654b7ab1686dac672fb83dfb4ba4096e8b5ffcdaccd262380ae58bec5e7" | 40 | SRC_URI[sha256sum] = "fd497654b7ab1686dac672fb83dfb4ba4096e8b5ffcdaccd262380ae58bec5e7" |
| 40 | 41 | ||
