diff options
| author | David Nyström <david.nystrom@est.tech> | 2025-10-15 14:20:28 +0200 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2025-10-24 06:23:40 -0700 |
| commit | 2142f17368af05bda2e77d00faef786da7fff8a2 (patch) | |
| tree | fa4f85caacd5257f16cf6f3fb28827eea834d576 /meta/recipes-connectivity | |
| parent | a7fdce2a68068ed3028914473578efd8c6a7c947 (diff) | |
| download | poky-2142f17368af05bda2e77d00faef786da7fff8a2.tar.gz | |
openssh: fix CVE-2025-61984
ssh in OpenSSH before 10.1 allows control characters in usernames that
originate from certain possibly untrusted sources, potentially leading
to code execution when a ProxyCommand is used. The untrusted sources
are the command line and %-sequence expansion of a configuration file.
Note:
openssh does not support variable expansion until 10.0, so backport
adapts for this.
Reference:
https://nvd.nist.gov/vuln/detail/CVE-2025-61984
Upstream patch:
https://github.com/openssh/openssh-portable/commit/35d5917652106aede47621bb3f64044604164043
(From OE-Core rev: 717d4c7609cdce2cc3a65b7ba69c316fa86a9333)
Signed-off-by: David Nyström <david.nystrom@est.tech>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta/recipes-connectivity')
| -rw-r--r-- | meta/recipes-connectivity/openssh/openssh/CVE-2025-61984.patch | 125 | ||||
| -rw-r--r-- | meta/recipes-connectivity/openssh/openssh_9.6p1.bb | 1 |
2 files changed, 126 insertions, 0 deletions
diff --git a/meta/recipes-connectivity/openssh/openssh/CVE-2025-61984.patch b/meta/recipes-connectivity/openssh/openssh/CVE-2025-61984.patch new file mode 100644 index 0000000000..f705410b24 --- /dev/null +++ b/meta/recipes-connectivity/openssh/openssh/CVE-2025-61984.patch | |||
| @@ -0,0 +1,125 @@ | |||
| 1 | From d45e13c956b296bf933901c4da2b61eb2ccd7582 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: "djm@openbsd.org" <djm@openbsd.org> | ||
| 3 | Date: Thu, 4 Sep 2025 00:29:09 +0000 | ||
| 4 | Subject: [PATCH] upstream: Improve rules for %-expansion of username. | ||
| 5 | MIME-Version: 1.0 | ||
| 6 | Content-Type: text/plain; charset=UTF-8 | ||
| 7 | Content-Transfer-Encoding: 8bit | ||
| 8 | |||
| 9 | Usernames passed on the commandline will no longer be subject to | ||
| 10 | % expansion. Some tools invoke ssh with connection information | ||
| 11 | (i.e. usernames and host names) supplied from untrusted sources. | ||
| 12 | These may contain % expansion sequences which could yield | ||
| 13 | unexpected results. | ||
| 14 | |||
| 15 | Since openssh-9.6, all usernames have been subject to validity | ||
| 16 | checking. This change tightens the validity checks by refusing | ||
| 17 | usernames that include control characters (again, these can cause | ||
| 18 | surprises when supplied adversarially). | ||
| 19 | |||
| 20 | This change also relaxes the validity checks in one small way: | ||
| 21 | usernames supplied via the configuration file as literals (i.e. | ||
| 22 | include no % expansion characters) are not subject to these | ||
| 23 | validity checks. This allows usernames that contain arbitrary | ||
| 24 | characters to be used, but only via configuration files. This | ||
| 25 | is done on the basis that ssh's configuration is trusted. | ||
| 26 | |||
| 27 | Pointed out by David Leadbeater, ok deraadt@ | ||
| 28 | |||
| 29 | OpenBSD-Commit-ID: e2f0c871fbe664aba30607321575e7c7fc798362 | ||
| 30 | |||
| 31 | Slightly modified since variable expansion of user names was | ||
| 32 | first released in 10.0, commit bd30cf784d6e8" | ||
| 33 | |||
| 34 | Upstream-Status: Backport [Upstream commit https://github.com/openssh/openssh-portable/commit/35d5917652106aede47621bb3f64044604164043] | ||
| 35 | CVE: CVE-2025-61984 | ||
| 36 | Signed-off-by: David Nyström <david.nystrom@est.tech> | ||
| 37 | --- | ||
| 38 | ssh.c | 26 +++++++++++++++++++++++--- | ||
| 39 | 1 file changed, 23 insertions(+), 3 deletions(-) | ||
| 40 | |||
| 41 | diff --git a/ssh.c b/ssh.c | ||
| 42 | index 48d93ddf2..9c49f98a8 100644 | ||
| 43 | --- a/ssh.c | ||
| 44 | +++ b/ssh.c | ||
| 45 | @@ -649,6 +649,8 @@ valid_ruser(const char *s) | ||
| 46 | if (*s == '-') | ||
| 47 | return 0; | ||
| 48 | for (i = 0; s[i] != 0; i++) { | ||
| 49 | + if (iscntrl((u_char)s[i])) | ||
| 50 | + return 0; | ||
| 51 | if (strchr("'`\";&<>|(){}", s[i]) != NULL) | ||
| 52 | return 0; | ||
| 53 | /* Disallow '-' after whitespace */ | ||
| 54 | @@ -671,6 +673,7 @@ main(int ac, char **av) | ||
| 55 | int i, r, opt, exit_status, use_syslog, direct, timeout_ms; | ||
| 56 | int was_addr, config_test = 0, opt_terminated = 0, want_final_pass = 0; | ||
| 57 | char *p, *cp, *line, *argv0, *logfile; | ||
| 58 | + int user_on_commandline = 0, user_was_default = 0; | ||
| 59 | char cname[NI_MAXHOST], thishost[NI_MAXHOST]; | ||
| 60 | struct stat st; | ||
| 61 | struct passwd *pw; | ||
| 62 | @@ -1016,8 +1019,10 @@ main(int ac, char **av) | ||
| 63 | } | ||
| 64 | break; | ||
| 65 | case 'l': | ||
| 66 | - if (options.user == NULL) | ||
| 67 | + if (options.user == NULL) { | ||
| 68 | options.user = optarg; | ||
| 69 | + user_on_commandline = 1; | ||
| 70 | + } | ||
| 71 | break; | ||
| 72 | |||
| 73 | case 'L': | ||
| 74 | @@ -1120,6 +1125,7 @@ main(int ac, char **av) | ||
| 75 | if (options.user == NULL) { | ||
| 76 | options.user = tuser; | ||
| 77 | tuser = NULL; | ||
| 78 | + user_on_commandline = 1; | ||
| 79 | } | ||
| 80 | free(tuser); | ||
| 81 | if (options.port == -1 && tport != -1) | ||
| 82 | @@ -1134,6 +1140,7 @@ main(int ac, char **av) | ||
| 83 | if (options.user == NULL) { | ||
| 84 | options.user = p; | ||
| 85 | p = NULL; | ||
| 86 | + user_on_commandline = 1; | ||
| 87 | } | ||
| 88 | *cp++ = '\0'; | ||
| 89 | host = xstrdup(cp); | ||
| 90 | @@ -1288,8 +1295,10 @@ main(int ac, char **av) | ||
| 91 | if (fill_default_options(&options) != 0) | ||
| 92 | cleanup_exit(255); | ||
| 93 | |||
| 94 | - if (options.user == NULL) | ||
| 95 | + if (options.user == NULL) { | ||
| 96 | + user_was_default = 1; | ||
| 97 | options.user = xstrdup(pw->pw_name); | ||
| 98 | + } | ||
| 99 | |||
| 100 | /* | ||
| 101 | * If ProxyJump option specified, then construct a ProxyCommand now. | ||
| 102 | @@ -1430,11 +1439,22 @@ main(int ac, char **av) | ||
| 103 | options.host_key_alias : options.host_arg); | ||
| 104 | cinfo->host_arg = xstrdup(options.host_arg); | ||
| 105 | cinfo->remhost = xstrdup(host); | ||
| 106 | - cinfo->remuser = xstrdup(options.user); | ||
| 107 | cinfo->homedir = xstrdup(pw->pw_dir); | ||
| 108 | cinfo->locuser = xstrdup(pw->pw_name); | ||
| 109 | cinfo->jmphost = xstrdup(options.jump_host == NULL ? | ||
| 110 | "" : options.jump_host); | ||
| 111 | + | ||
| 112 | + /* | ||
| 113 | + * Usernames specified on the commandline must be validated. | ||
| 114 | + * Conversely, usernames from getpwnam(3) or specified as literals | ||
| 115 | + * via configuration (i.e. not expanded) are not subject to validation. | ||
| 116 | + */ | ||
| 117 | + if (user_on_commandline && !valid_ruser(options.user)) | ||
| 118 | + fatal("remote username contains invalid characters"); | ||
| 119 | + | ||
| 120 | + /* Store it and calculate hash. */ | ||
| 121 | + cinfo->remuser = xstrdup(options.user); | ||
| 122 | + | ||
| 123 | cinfo->conn_hash_hex = ssh_connection_hash(cinfo->thishost, | ||
| 124 | cinfo->remhost, cinfo->portstr, cinfo->remuser, cinfo->jmphost); | ||
| 125 | |||
diff --git a/meta/recipes-connectivity/openssh/openssh_9.6p1.bb b/meta/recipes-connectivity/openssh/openssh_9.6p1.bb index bdb8a1599b..1cdd888ccb 100644 --- a/meta/recipes-connectivity/openssh/openssh_9.6p1.bb +++ b/meta/recipes-connectivity/openssh/openssh_9.6p1.bb | |||
| @@ -33,6 +33,7 @@ SRC_URI = "http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-${PV}.tar | |||
| 33 | file://CVE-2025-26465.patch \ | 33 | file://CVE-2025-26465.patch \ |
| 34 | file://CVE-2025-32728.patch \ | 34 | file://CVE-2025-32728.patch \ |
| 35 | file://CVE-2025-61985.patch \ | 35 | file://CVE-2025-61985.patch \ |
| 36 | file://CVE-2025-61984.patch \ | ||
| 36 | " | 37 | " |
| 37 | SRC_URI[sha256sum] = "910211c07255a8c5ad654391b40ee59800710dd8119dd5362de09385aa7a777c" | 38 | SRC_URI[sha256sum] = "910211c07255a8c5ad654391b40ee59800710dd8119dd5362de09385aa7a777c" |
| 38 | 39 | ||
