[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openembedded-core
Subject:    Re: [OE-core][dunfell 02/14] openssh: Fix CVE-2021-41617
From:       "Jacob Kroon" <jacob.kroon () gmail ! com>
Date:       2021-12-30 21:59:45
Message-ID: CAPbeDCm1Z0n9kuLSi4FsVPRsYwyzcpRv1cnXp5n0d-Pv9RxFmg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On Thu, 30 Dec 2021, 21:17 Steve Sakoman, <steve@sakoman.com> wrote:

On Thu, Dec 30, 2021 at 9:04 AM Jacob Kroon <jacob.kroon@gmail.com> wrote:
>
> On 12/30/21 19:54, Jacob Kroon via lists.openembedded.org wrote:
> > On 12/22/21 15:12, Steve Sakoman wrote:
> >> From: sana kazi <sanakazisk19@gmail.com>
> >>
> >> Add patch to fix CVE-2021-41617
> >> Link: https://bugzilla.suse.com/attachment.cgi?id=854015
> >>
> >> Signed-off-by: Sana Kazi <Sana.Kazi@kpit.com>
> >> Signed-off-by: Sana Kazi <sanakazisk19@gmail.com>
> >> Signed-off-by: Steve Sakoman <steve@sakoman.com>
> >> ---
> >>  .../openssh/openssh/CVE-2021-41617.patch      | 52 +++++++++++++++++++
> >>  .../openssh/openssh_8.2p1.bb                  |  1 +
> >>  2 files changed, 53 insertions(+)
> >>  create mode 100644
meta/recipes-connectivity/openssh/openssh/CVE-2021-41617.patch
> >>
> >> diff --git
a/meta/recipes-connectivity/openssh/openssh/CVE-2021-41617.patch
b/meta/recipes-connectivity/openssh/openssh/CVE-2021-41617.patch
> >> new file mode 100644
> >> index 0000000000..bda896f581
> >> --- /dev/null
> >> +++ b/meta/recipes-connectivity/openssh/openssh/CVE-2021-41617.patch
> >> @@ -0,0 +1,52 @@
> >> +From a6414400ec94a17871081f7df24f910a6ee01b8b Mon Sep 17 00:00:00 2001
> >> +From: Ali Abdallah <aabdallah@suse.de>
> >> +Date: Wed, 24 Nov 2021 13:33:39 +0100
> >> +Subject: [PATCH] CVE-2021-41617 fix
> >> +
> >> +backport of the following two upstream commits
> >> +
> >> +f3cbe43e28fe71427d41cfe3a17125b972710455
> >> +bf944e3794eff5413f2df1ef37cddf96918c6bde
> >> +
> >> +CVE-2021-41617 failed to correctly initialise supplemental groups
> >> +when executing an AuthorizedKeysCommand or
AuthorizedPrincipalsCommand,
> >> +where a AuthorizedKeysCommandUser or AuthorizedPrincipalsCommandUser
> >> +directive has been set to run the command as a different user. Instead
> >> +these commands would inherit the groups that sshd(8) was started with.
> >> +---
> >> + auth.c | 8 ++++++++
> >> + 1 file changed, 8 insertions(+)
> >> +
> >> +CVE: CVE-2021-41617
> >> +Upstream-Status: Backport [
https://bugzilla.suse.com/attachment.cgi?id=854015]
> >> +Comment: No change in any hunk
> >> +Signed-off-by: Sana Kazi <Sana.Kazi@kpit.com>
> >> +
> >> +diff --git a/auth.c b/auth.c
> >> +index 163038f..a47b267 100644
> >> +--- a/auth.c
> >> ++++ b/auth.c
> >> +@@ -52,6 +52,7 @@
> >> + #include <limits.h>
> >> + #include <netdb.h>
> >> + #include <time.h>
> >> ++#include <grp.h>
> >> +
> >> + #include "xmalloc.h"
> >> + #include "match.h"
> >> +@@ -851,6 +852,13 @@ subprocess(const char *tag, struct passwd *pw,
const char *command,
> >> +            }
> >> +            closefrom(STDERR_FILENO + 1);
> >> +
> >> ++           if (geteuid() == 0 &&
> >> ++               initgroups(pw->pw_name, pw->pw_gid) == -1) {
> >> ++                   error("%s: initgroups(%s, %u): %s", tag,
> >> ++                       pw->pw_name, (u_int)pw->pw_gid,
strerror(errno));
> >> ++                   _exit(1);
> >> ++           }
> >> ++
> >> +            /* Don't use permanently_set_uid() here to avoid fatal()
*/
> >> +            if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) == -1) {
> >> +                    error("%s: setresgid %u: %s", tag,
(u_int)pw->pw_gid,
> >> +--
> >> +2.26.2
> >> diff --git a/meta/recipes-connectivity/openssh/openssh_8.2p1.bb
 b/meta/recipes-connectivity/openssh/openssh_8.2p1.bb
> >> index b60d1a6bd4..e903ec487d 100644
> >> --- a/meta/recipes-connectivity/openssh/openssh_8.2p1.bb
> >> +++ b/meta/recipes-connectivity/openssh/openssh_8.2p1.bb
> >> @@ -26,6 +26,7 @@ SRC_URI = "
http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-${PV}.tar
> >>             file://add-test-support-for-busybox.patch \
> >>             file://CVE-2020-14145.patch \
> >>             file://CVE-2021-28041.patch \
> >> +           file://CVE-2021-41617.patch \
> >>             "
> >>  SRC_URI[md5sum] = "3076e6413e8dbe56d33848c1054ac091"
> >>  SRC_URI[sha256sum] =
"43925151e6cf6cee1450190c0e9af4dc36b41c12737619edff8bcebdff64e671"
> >>
> >>
> >>
> >>
> >>
> >
> > I would have expected this patch to leave a mark in my buildhistory, but
> > nothing related to openssh(d) shows up.
> >
> > Size of /usr/sbin/sshd stays the same, which at least to me is a little
> > odd.. but I can see that the sha256sum output of sshd changes.
> >
> > (It would be nice to have sha256sum hashes of files in buildhistory)
> >
> > Am I the only one who thinks this is a little strange ?
> >
> > /Jacob
> >
>
> Let me rephrase, I do see changes related to debug information and the
> debug package, but no change in the resulting '/usr/sbin/sshd' size that
> goes in the final image.

Yes, it is unusual that the size of sshd is the same pre and post patch.

I checked the size of auth.o pre and post patch, and it is also the
same (not surprisingly!)

However I've verified that the patch modifies auth.c as desired, and
the md5sums for both auth.o and ssshd are different pre and post patch
(as expected)

So this is just one of those cases where different code results in the
same size!

Steve


Thanks for double checking.
/Jacob

[Attachment #5 (text/html)]

<div dir="auto"><div dir="auto"><div class="elided-text" dir="auto"><div dir="ltr">On \
Thu, 30 Dec 2021, 21:17 Steve Sakoman, &lt;<a \
href="mailto:steve@sakoman.com">steve@sakoman.com</a>&gt; wrote:<br></div><blockquote \
style="margin:0px 0px 0px 0.8ex;border-left:1px solid \
rgb(204,204,204);padding-left:1ex">On Thu, Dec 30, 2021 at 9:04 AM Jacob Kroon &lt;<a \
href="mailto:jacob.kroon@gmail.com">jacob.kroon@gmail.com</a>&gt; \
wrote:<br>&gt;<br>&gt; On 12/30/21 19:54, Jacob Kroon via  <a \
href="http://lists.openembedded.org/">lists.openembedded.org</a>  wrote:<br>&gt; &gt; \
On 12/22/21 15:12, Steve Sakoman wrote:<br>&gt; &gt;&gt; From: sana kazi &lt;<a \
href="mailto:sanakazisk19@gmail.com">sanakazisk19@gmail.com</a>&gt;<br>&gt; \
&gt;&gt;<br>&gt; &gt;&gt; Add patch to fix CVE-2021-41617<br>&gt; &gt;&gt; Link:  <a \
href="https://bugzilla.suse.com/attachment.cgi?id=854015">https://bugzilla.suse.com/attachment.cgi?id=854015</a><br>&gt; \
&gt;&gt;<br>&gt; &gt;&gt; Signed-off-by: Sana Kazi &lt;<a \
href="mailto:Sana.Kazi@kpit.com">Sana.Kazi@kpit.com</a>&gt;<br>&gt; &gt;&gt; \
Signed-off-by: Sana Kazi &lt;<a \
href="mailto:sanakazisk19@gmail.com">sanakazisk19@gmail.com</a>&gt;<br>&gt; &gt;&gt; \
Signed-off-by: Steve Sakoman &lt;<a \
href="mailto:steve@sakoman.com">steve@sakoman.com</a>&gt;<br>&gt; &gt;&gt; \
---<br>&gt; &gt;&gt;   .../openssh/openssh/CVE-2021-41617.patch         | 52 \
+++++++++++++++++++<br>&gt; &gt;&gt;   .../openssh/<a \
href="http://openssh_8.2p1.bb/">openssh_8.2p1.bb</a>                           |   1 \
+<br>&gt; &gt;&gt;   2 files changed, 53 insertions(+)<br>&gt; &gt;&gt;   create mode \
100644 meta/recipes-connectivity/openssh/openssh/CVE-2021-41617.patch<br>&gt; \
&gt;&gt;<br>&gt; &gt;&gt; diff --git \
a/meta/recipes-connectivity/openssh/openssh/CVE-2021-41617.patch \
b/meta/recipes-connectivity/openssh/openssh/CVE-2021-41617.patch<br>&gt; &gt;&gt; new \
file mode 100644<br>&gt; &gt;&gt; index 0000000000..bda896f581<br>&gt; &gt;&gt; --- \
/dev/null<br>&gt; &gt;&gt; +++ \
b/meta/recipes-connectivity/openssh/openssh/CVE-2021-41617.patch<br>&gt; &gt;&gt; @@ \
-0,0 +1,52 @@<br>&gt; &gt;&gt; +From a6414400ec94a17871081f7df24f910a6ee01b8b Mon Sep \
17 00:00:00 2001<br>&gt; &gt;&gt; +From: Ali Abdallah &lt;<a \
href="mailto:aabdallah@suse.de">aabdallah@suse.de</a>&gt;<br>&gt; &gt;&gt; +Date: \
Wed, 24 Nov 2021 13:33:39 +0100<br>&gt; &gt;&gt; +Subject: [PATCH] CVE-2021-41617 \
fix<br>&gt; &gt;&gt; +<br>&gt; &gt;&gt; +backport of the following two upstream \
commits<br>&gt; &gt;&gt; +<br>&gt; &gt;&gt; \
+f3cbe43e28fe71427d41cfe3a17125b972710455<br>&gt; &gt;&gt; \
+bf944e3794eff5413f2df1ef37cddf96918c6bde<br>&gt; &gt;&gt; +<br>&gt; &gt;&gt; \
+CVE-2021-41617 failed to correctly initialise supplemental groups<br>&gt; &gt;&gt; \
+when executing an AuthorizedKeysCommand or AuthorizedPrincipalsCommand,<br>&gt; \
&gt;&gt; +where a AuthorizedKeysCommandUser or \
AuthorizedPrincipalsCommandUser<br>&gt; &gt;&gt; +directive has been set to run the \
command as a different user. Instead<br>&gt; &gt;&gt; +these commands would inherit \
the groups that sshd(8) was started with.<br>&gt; &gt;&gt; +---<br>&gt; &gt;&gt; + \
auth.c | 8 ++++++++<br>&gt; &gt;&gt; + 1 file changed, 8 insertions(+)<br>&gt; \
&gt;&gt; +<br>&gt; &gt;&gt; +CVE: CVE-2021-41617<br>&gt; &gt;&gt; +Upstream-Status: \
Backport [<a href="https://bugzilla.suse.com/attachment.cgi?id=854015">https://bugzilla.suse.com/attachment.cgi?id=854015</a>]<br>&gt; \
&gt;&gt; +Comment: No change in any hunk<br>&gt; &gt;&gt; +Signed-off-by: Sana Kazi \
&lt;<a href="mailto:Sana.Kazi@kpit.com">Sana.Kazi@kpit.com</a>&gt;<br>&gt; &gt;&gt; \
+<br>&gt; &gt;&gt; +diff --git a/auth.c b/auth.c<br>&gt; &gt;&gt; +index \
163038f..a47b267 100644<br>&gt; &gt;&gt; +--- a/auth.c<br>&gt; &gt;&gt; ++++ \
b/auth.c<br>&gt; &gt;&gt; +@@ -52,6 +52,7 @@<br>&gt; &gt;&gt; + #include \
&lt;limits.h&gt;<br>&gt; &gt;&gt; + #include &lt;netdb.h&gt;<br>&gt; &gt;&gt; + \
#include &lt;time.h&gt;<br>&gt; &gt;&gt; ++#include &lt;grp.h&gt;<br>&gt; &gt;&gt; \
+<br>&gt; &gt;&gt; + #include &quot;xmalloc.h&quot;<br>&gt; &gt;&gt; + #include \
&quot;match.h&quot;<br>&gt; &gt;&gt; +@@ -851,6 +852,13 @@ subprocess(const char \
*tag, struct passwd *pw, const char *command,<br>&gt; &gt;&gt; +                  \
}<br>&gt; &gt;&gt; +                  closefrom(STDERR_FILENO + 1);<br>&gt; &gt;&gt; \
+<br>&gt; &gt;&gt; ++                 if (geteuid() == 0 &amp;&amp;<br>&gt; &gt;&gt; \
++                       initgroups(pw-&gt;pw_name, pw-&gt;pw_gid) == -1) {<br>&gt; \
&gt;&gt; ++                             error(&quot;%s: initgroups(%s, %u): %s&quot;, \
tag,<br>&gt; &gt;&gt; ++                                   pw-&gt;pw_name, \
(u_int)pw-&gt;pw_gid, strerror(errno));<br>&gt; &gt;&gt; ++                           \
_exit(1);<br>&gt; &gt;&gt; ++                 }<br>&gt; &gt;&gt; ++<br>&gt; &gt;&gt; \
+                  /* Don&#39;t use permanently_set_uid() here to avoid fatal() \
*/<br>&gt; &gt;&gt; +                  if (setresgid(pw-&gt;pw_gid, pw-&gt;pw_gid, \
pw-&gt;pw_gid) == -1) {<br>&gt; &gt;&gt; +                              \
error(&quot;%s: setresgid %u: %s&quot;, tag, (u_int)pw-&gt;pw_gid,<br>&gt; &gt;&gt; \
+--<br>&gt; &gt;&gt; +2.26.2<br>&gt; &gt;&gt; diff --git \
a/meta/recipes-connectivity/openssh/<a \
href="http://openssh_8.2p1.bb/">openssh_8.2p1.bb</a>  \
b/meta/recipes-connectivity/openssh/<a \
href="http://openssh_8.2p1.bb/">openssh_8.2p1.bb</a><br>&gt; &gt;&gt; index \
b60d1a6bd4..e903ec487d 100644<br>&gt; &gt;&gt; --- \
a/meta/recipes-connectivity/openssh/<a \
href="http://openssh_8.2p1.bb/">openssh_8.2p1.bb</a><br>&gt; &gt;&gt; +++ \
b/meta/recipes-connectivity/openssh/<a \
href="http://openssh_8.2p1.bb/">openssh_8.2p1.bb</a><br>&gt; &gt;&gt; @@ -26,6 +26,7 \
@@ SRC_URI = &quot;<a \
href="http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-$%7BPV%7D.tar">http://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-${PV}.tar</a><br>&gt; \
&gt;&gt;                    file://add-test-support-for-busybox.patch \<br>&gt; \
&gt;&gt;                    file://CVE-2020-14145.patch \<br>&gt; &gt;&gt;            \
file://CVE-2021-28041.patch \<br>&gt; &gt;&gt; +                 \
file://CVE-2021-41617.patch \<br>&gt; &gt;&gt;                    &quot;<br>&gt; \
&gt;&gt;   SRC_URI[md5sum] = &quot;3076e6413e8dbe56d33848c1054ac091&quot;<br>&gt; \
&gt;&gt;   SRC_URI[sha256sum] = \
&quot;43925151e6cf6cee1450190c0e9af4dc36b41c12737619edff8bcebdff64e671&quot;<br>&gt; \
&gt;&gt;<br>&gt; &gt;&gt;<br>&gt; &gt;&gt;<br>&gt; &gt;&gt;<br>&gt; &gt;&gt;<br>&gt; \
&gt;<br>&gt; &gt; I would have expected this patch to leave a mark in my \
buildhistory, but<br>&gt; &gt; nothing related to openssh(d) shows up.<br>&gt; \
&gt;<br>&gt; &gt; Size of /usr/sbin/sshd stays the same, which at least to me is a \
little<br>&gt; &gt; odd.. but I can see that the sha256sum output of sshd \
changes.<br>&gt; &gt;<br>&gt; &gt; (It would be nice to have sha256sum hashes of \
files in buildhistory)<br>&gt; &gt;<br>&gt; &gt; Am I the only one who thinks this is \
a little strange ?<br>&gt; &gt;<br>&gt; &gt; /Jacob<br>&gt; &gt;<br>&gt;<br>&gt; Let \
me rephrase, I do see changes related to debug information and the<br>&gt; debug \
package, but no change in the resulting &#39;/usr/sbin/sshd&#39; size that<br>&gt; \
goes in the final image.<br><br>Yes, it is unusual that the size of sshd is the same \
pre and post patch.<br><br>I checked the size of auth.o pre and post patch, and it is \
also the<br>same (not surprisingly!)<br><br>However I&#39;ve verified that the patch \
modifies auth.c as desired, and<br>the md5sums for both auth.o and ssshd are \
different pre and post patch<br>(as expected)<br><br>So this is just one of those \
cases where different code results in the<br>same \
size!<br><br>Steve</blockquote></div></div><div dir="auto"><br></div>Thanks for \
double checking.<div dir="auto">/Jacob</div></div>



-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#160067): https://lists.openembedded.org/g/openembedded-core/message/160067
Mute This Topic: https://lists.openembedded.org/mt/87898179/4454766
Group Owner: openembedded-core+owner@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [openembedded-core@marc.info]
-=-=-=-=-=-=-=-=-=-=-=-



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic