• Vulnerability in pcs or is it in more generic code?

    From Ola Lundqvist@21:1/5 to All on Mon Sep 5 22:00:01 2022
    Hi fellow Debian LTS and Debian Security memebers

    When triaging the packages for LTS I looked into the package pcs. I saw
    that it was already added to DSA needed so I have added it to DLA needed as well. However when reading the correction for it I started to think that
    the vulnerability may not be in PCS itself, but rather in Thin::Backends::UnixServer::connect because the correction is to override
    that function with a more secure umask.

    I agree that it is good to fix the pcs package, but shouldn't we fix the default umask in general?
    I would argue that the default umask is insecure.

    What do you think?

    Cheers

    // Ola

    --
    --- Inguza Technology AB --- MSc in Information Technology ----
    | ola@inguza.com opal@debian.org |
    | http://inguza.com/ Mobile: +46 (0)70-332 1551 |
    ---------------------------------------------------------------

    <div dir="ltr">Hi fellow Debian LTS and Debian Security memebers<div><br></div><div>When triaging the packages for LTS I looked into the package pcs. I saw that it was already added to DSA needed so I have added it to DLA needed as well. However when
    reading the correction for it I started to think that the vulnerability may not be in PCS itself, but rather in Thin::Backends::UnixServer::connect because the correction is to override that function with a more secure umask.</div><div><br></div><div>I
    agree that it is good to fix the pcs package, but shouldn&#39;t we fix the default umask in general?</div><div>I would argue that the default umask is insecure.</div><div><br></div><div>What do you think?</div><div><br></div><div>Cheers</div><div><br></
    <div>// Ola</div><div><br></div><div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><div><font face="courier new, monospace" size="1"> --- Inguza Technology AB ---
    MSc in Information Technology ----</font></div><div><font face="courier new, monospace" size="1">|  </font><a href="mailto:ola@inguza.com" style="font-family:&quot;courier new&quot;,monospace;font-size:x-small" target="_blank">ola@inguza.com</a><span
    style="font-family:&quot;courier new&quot;,monospace;font-size:x-small">                    </span><a href="mailto:opal@debian.org" style="font-family:&quot;courier new&quot;,monospace;font-size:x-small" target="_blank">opal@debian.org</a><
    span style="font-family:&quot;courier new&quot;,monospace;font-size:x-small">            |</span></div><div><font face="courier new, monospace" size="1">|  <a href="http://inguza.com/" target="_blank">http://inguza.com/</a>                
    Mobile: +46 (0)70-332 1551 |</font></div><div><font face="courier new, monospace" size="1"> ---------------------------------------------------------------</font></div></div><div><br></div></div></div></div></div></div></div></div>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul Wise@21:1/5 to Ola Lundqvist on Tue Sep 6 03:10:01 2022
    On Mon, 2022-09-05 at 21:38 +0200, Ola Lundqvist wrote:

    I agree that it is good to fix the pcs package, but shouldn't we fix
    the default umask in general?
    I would argue that the default umask is insecure.

    bookworm login sets new user home directories to secure permissions:

    $ grep -E 'HOME_MODE\s*[0-9]' /etc/login.defs
    #HOME_MODE 0700

    This somewhat mitigates, but not completely, the umask being insecure:

    $ grep -E 'UMASK\s*[0-9]' /etc/login.defs
    UMASK 022

    I can't find any bugs open about changing the default umask,
    but it was mentioned in replies to the recent adduser thread:

    https://lists.debian.org/msgid-search/YieJALY0ny0+07pw@torres.zugschlus.de

    --
    bye,
    pabs

    https://wiki.debian.org/PaulWise

    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEEYQsotVz8/kXqG1Y7MRa6Xp/6aaMFAmMWnakACgkQMRa6Xp/6 aaOOXg/9FhVggWcmtOQqbJanScUB/3BE36I1MQYypr4jyIPkqZvwZ5mZ2AtNRz6+ aDaTT0F1EidmHXGZNi6Nkiq3CRLm5FAleVhLt1BzOYsqRa6F/p9dkYiGXDciOoZ7 EAZ8qimqDnT5F9CvpzDlJfZOHJSMgvsi7XZElLxkCuReOtEbD+9chGY3SLmK7Xvb B+9U5dxk85cR443yAtX6aOQUwsIJArhsn5bkePUOku+qJYYdNxVG5QXOkZ4j5oCM 3WN4r1Q+Z6ClRuiPSHl9OWBr38PLUUq3G4UOsAYgknY1ymIfqpC6R6ej5UyrIz51 dRocjxolC5U3aiWoZck6l6njwPhWOUIvRVL/WTf67R36fKuHXmOkOc4Hq54V7m4B p+TrGeTxnJ0tWk4Hcsb1mP/t9CrRR47sX+HMZbKin285nf64LGDcAgcnasWEju24 OVr9lG2/nGMcdnRLMdplNY292RyB6LG9fiZnFl9aog6fyTnoq/vp7/JB/CwKcSWl P5XliTEOrf4luFHQrujIdUewQC6lhtzQynapv2x8l7FWVIatQow9NWTN6zBqlR/x u6lZ5tmoD/bMZa6GdGlI/7DsatPi5N5A/oX4HCCxiNdC5M6pj8uQSapf6IPzykR+ BmtFm/TBVgd08WfbjYU8mps5F8mNBLQiLOUMJgtcPf+gcHovwas=
    =ujwc
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ola Lundqvist@21:1/5 to Paul Wise on Fri Sep 9 23:10:01 2022
    Hi Paul

    I see that I was not clear what I meant with "in general" :-)

    In the fix for pcs https://github.com/ClusterLabs/pcs/commit/de068e2066e377d1cc77edf25aed0198e4c77f7b
    you can see a comment that there is a change from umask(0) to umask(0x077)

    It was this umask(0) (in Thin::Backends::UnixServer#connect) I was
    referring to as "in general".

    I mean the fix is to override this more generic function that is obviously
    not secure enough.

    Here I found how the generic source code looks like: https://rubydoc.info/gems/thin/1.3.1/Thin%2FBackends%2FUnixServer:connect

    You can see the umask(0) there.

    That is what I think is insecure, not pcs itself.

    It looks like pcs code was not vulnerable because what I missed to check
    was whether this source code was present in buster. It was not as someone
    have concluded.

    But I think Thin::Backends::UnixServer#connect is still insecure.

    Cheers

    // Ola

    On Tue, 6 Sept 2022 at 03:09, Paul Wise <pabs@debian.org> wrote:

    On Mon, 2022-09-05 at 21:38 +0200, Ola Lundqvist wrote:

    I agree that it is good to fix the pcs package, but shouldn't we fix
    the default umask in general?
    I would argue that the default umask is insecure.

    bookworm login sets new user home directories to secure permissions:

    $ grep -E 'HOME_MODE\s*[0-9]' /etc/login.defs
    #HOME_MODE 0700

    This somewhat mitigates, but not completely, the umask being insecure:

    $ grep -E 'UMASK\s*[0-9]' /etc/login.defs
    UMASK 022

    I can't find any bugs open about changing the default umask,
    but it was mentioned in replies to the recent adduser thread:

    https://lists.debian.org/msgid-search/YieJALY0ny0+07pw@torres.zugschlus.de

    --
    bye,
    pabs

    https://wiki.debian.org/PaulWise



    --
    --- Inguza Technology AB --- MSc in Information Technology ----
    | ola@inguza.com opal@debian.org |
    | http://inguza.com/ Mobile: +46 (0)70-332 1551 |
    ---------------------------------------------------------------

    <div dir="ltr">Hi Paul<div><br></div><div>I see that I was not clear what I meant with &quot;in general&quot; :-)</div><div><br></div><div>In the fix for pcs</div><div><a href="https://github.com/ClusterLabs/pcs/commit/
    de068e2066e377d1cc77edf25aed0198e4c77f7b">https://github.com/ClusterLabs/pcs/commit/de068e2066e377d1cc77edf25aed0198e4c77f7b</a><br></div><div>you can see a comment that there is a change from umask(0) to umask(0x077)</div><div><br></div><div>It was this
    umask(0) (in Thin::Backends::UnixServer#connect) I was referring to as &quot;in general&quot;.</div><div><br></div><div>I mean the fix is to override this more generic function that is obviously not secure enough.</div><div><br></div><div>Here I found
    how the generic source code looks like:</div><div><a href="https://rubydoc.info/gems/thin/1.3.1/Thin%2FBackends%2FUnixServer:connect">https://rubydoc.info/gems/thin/1.3.1/Thin%2FBackends%2FUnixServer:connect</a><br></div><div><br></div><div>You can see
    the umask(0) there.</div><div><br></div><div>That is what I think is insecure, not pcs itself.</div><div><br></div><div>It looks like pcs code was not vulnerable because what I missed to check was whether this source code was present in buster. It was
    not as someone have concluded.</div><div><br></div><div>But I think Thin::Backends::UnixServer#connect is still insecure.</div><div><br></div><div>Cheers</div><div><br></div><div>// Ola</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_
    attr">On Tue, 6 Sept 2022 at 03:09, Paul Wise &lt;<a href="mailto:pabs@debian.org">pabs@debian.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Mon,
    2022-09-05 at 21:38 +0200, Ola Lundqvist wrote:<br>

    &gt; I agree that it is good to fix the pcs package, but shouldn&#39;t we fix<br>
    &gt; the default umask in general?<br>
    &gt; I would argue that the default umask is insecure.<br>

    bookworm login sets new user home directories to secure permissions:<br>

       $ grep -E &#39;HOME_MODE\s*[0-9]&#39; /etc/login.defs <br>
       #HOME_MODE   0700<br>

    This somewhat mitigates, but not completely, the umask being insecure:<br>

       $ grep -E &#39;UMASK\s*[0-9]&#39; /etc/login.defs <br>
       UMASK                022<br>

    I can&#39;t find any bugs open about changing the default umask,<br>
    but it was mentioned in replies to the recent adduser thread:<br>

    <a href="https://lists.debian.org/msgid-search/YieJALY0ny0+07pw@torres.zugschlus.de" rel="noreferrer" target="_blank">https://lists.debian.org/msgid-search/YieJALY0ny0+07pw@torres.zugschlus.de</a><br>

    -- <br>
    bye,<br>
    pabs<br>

    <a href="https://wiki.debian.org/PaulWise" rel="noreferrer" target="_blank">https://wiki.debian.org/PaulWise</a><br>
    </blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><div><font face="courier new, monospace" size="1"> --- Inguza Technology AB --- MSc in Information
    Technology ----</font></div><div><font face="courier new, monospace" size="1">|  </font><a href="mailto:ola@inguza.com" style="font-family:&quot;courier new&quot;,monospace;font-size:x-small" target="_blank">ola@inguza.com</a><span style="font-family:&
    quot;courier new&quot;,monospace;font-size:x-small">                    </span><a href="mailto:opal@debian.org" style="font-family:&quot;courier new&quot;,monospace;font-size:x-small" target="_blank">opal@debian.org</a><span style="font-family:
    &quot;courier new&quot;,monospace;font-size:x-small">            |</span></div><div><font face="courier new, monospace" size="1">|  <a href="http://inguza.com/" target="_blank">http://inguza.com/</a>                Mobile: +46 (0)70-332
    1551 |</font></div><div><font face="courier new, monospace" size="1"> ---------------------------------------------------------------</font></div></div><div><br></div></div></div></div></div></div>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul Wise@21:1/5 to Ola Lundqvist on Sat Sep 10 03:40:01 2022
    On Fri, 2022-09-09 at 22:41 +0200, Ola Lundqvist wrote:

    I see that I was not clear what I meant with "in general" :-)

    Woops, sorry for the noise :)

    Here I found how the generic source code looks like: https://rubydoc.info/gems/thin/1.3.1/Thin%2FBackends%2FUnixServer:connect

    You can see the umask(0) there.

    That is what I think is insecure, not pcs itself.

    Agreed.

    But I think Thin::Backends::UnixServer#connect is still insecure.

    It looks like the issue was introduced in this pull request:

       https://github.com/macournoyer/thin/pull/28

    It sounds like unicorn might have the same issue as thin.

    Looking at the unicorn code, it sets the default umask to 0
    when the umask option is not set, so not quite as bad but still.

    The justification for the default umask of 0 in unicorn is:

       #   Typically UNIX domain sockets are created with more liberal
       #   file permissions than the rest of the application.  By default,    #   we create UNIX domain sockets to be readable and writable by
       #   all local users to give them the same accessibility as
       #   locally-bound TCP listeners.

    So the choice of umask 0 is deliberate in unicorn and the thin folks
    copied that choice and dropped the possibility of overriding it,
    since they did't have an options argument for the function.

    Since UNIX domain sockets are often used for situations that are not
    like localhost TCP sockets, that was probably the wrong choice, but
    the unicorn/thin folks are likely from the web developer community,
    which is mostly focused on HTTP and TCP and often use localhost for development, so it was the right choice within their bubble.

    I feel like the APIs of both thin and unicorn need redesigning so that
    the choice of umask to use must be made by the caller. Then the web
    developer community can use 0 and others will choose a safe value.

    Really the web developer community shouldn't use 0 either but I expect
    that convincing them of that might not be possible.

    I'm not sure how palatable the API change will be to thin/unicorn.

    --
    bye,
    pabs

    https://wiki.debian.org/PaulWise

    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEEYQsotVz8/kXqG1Y7MRa6Xp/6aaMFAmMb6e8ACgkQMRa6Xp/6 aaOSqw/9HJih85OjQfSJ9lTL2GTTCAlx3hXxbUuymadjXE15X430nyArUuwlI7VI cbTUHjEryQkOsT9camKsW0OnnxRyYI1cG/L+/Z47Bv1inokTBeVVk8lKd6uzylAp 9sG0mTQzrrsA1r1DGMjIHZhn3yDz7oUFzmzCdnyOtMQiUZzW+Jj9FYSN3ijsCQH6 vY8Bxwu2znUwuetMYlA+jW44EjjtLFflc3myd1EAWB6gIEhf51Z0WjmRunHlOYPW RRlqVe8+SmIaRjouiw7etP9FjHKyOdI/WAO1XnwHJEgaVpqRCq5KaYxAnG1Pmctz Kv0vsT5xsphp4IMC2Yg/L7h3A7hJu2lAiN9ZDFQBX701sfxXj8fYFbBtX8GfXRzI 4vsVbI32YorGNVRb4xTR23XGpVs30yvYa4YtfEAZXsfXxSVihuOkHjkMbQmd/RS8 YrEEFlJyhVmyirIS8Zhhi/WPdUtH0fMniVxtjXk8wA/3RdYnU0gEmrsb2GFW1CcM V9w3abCKx4jHtJoFRo2NgxXFuzXWjhZbisl020yJ6+3hhbbs6qmgStQaVHe1dlvF u9ew68X3+X4m7uO1ikWcLLGEdkqs83YAkGeTnQzuhDPQ09k5qMw3O2V2XAv107XV IlBzRrWwAvpvLPDsuxFyoyJGzII/kthmeye5EEn7IvVG/G4MRoo=
    =iWNv
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ola Lundqvist@21:1/5 to Paul Wise on Sat Sep 10 23:50:01 2022
    Hi Paul

    Thank you for pointing out the reason why umask 0 is used. I think it is reasonable.
    I think it would be a good thing if the caller could tell the umask to use,
    or alternatively use different functions.
    But I let other people handle that.

    Your explanation shows that the vulnerability is in pcs only and the
    generic code is not vulnerable since the intention was not to use it for internal communication without further authentication or similar.

    Cheers

    // Ola

    On Sat, 10 Sept 2022 at 03:36, Paul Wise <pabs@debian.org> wrote:

    On Fri, 2022-09-09 at 22:41 +0200, Ola Lundqvist wrote:

    I see that I was not clear what I meant with "in general" :-)

    Woops, sorry for the noise :)

    Here I found how the generic source code looks like:

    https://rubydoc.info/gems/thin/1.3.1/Thin%2FBackends%2FUnixServer:connect

    You can see the umask(0) there.

    That is what I think is insecure, not pcs itself.

    Agreed.

    But I think Thin::Backends::UnixServer#connect is still insecure.

    It looks like the issue was introduced in this pull request:

    https://github.com/macournoyer/thin/pull/28

    It sounds like unicorn might have the same issue as thin.

    Looking at the unicorn code, it sets the default umask to 0
    when the umask option is not set, so not quite as bad but still.

    The justification for the default umask of 0 in unicorn is:

    # Typically UNIX domain sockets are created with more liberal
    # file permissions than the rest of the application. By default,
    # we create UNIX domain sockets to be readable and writable by
    # all local users to give them the same accessibility as
    # locally-bound TCP listeners.

    So the choice of umask 0 is deliberate in unicorn and the thin folks
    copied that choice and dropped the possibility of overriding it,
    since they did't have an options argument for the function.

    Since UNIX domain sockets are often used for situations that are not
    like localhost TCP sockets, that was probably the wrong choice, but
    the unicorn/thin folks are likely from the web developer community,
    which is mostly focused on HTTP and TCP and often use localhost for development, so it was the right choice within their bubble.

    I feel like the APIs of both thin and unicorn need redesigning so that
    the choice of umask to use must be made by the caller. Then the web
    developer community can use 0 and others will choose a safe value.

    Really the web developer community shouldn't use 0 either but I expect
    that convincing them of that might not be possible.

    I'm not sure how palatable the API change will be to thin/unicorn.

    --
    bye,
    pabs

    https://wiki.debian.org/PaulWise



    --
    --- Inguza Technology AB --- MSc in Information Technology ----
    | ola@inguza.com opal@debian.org |
    | http://inguza.com/ Mobile: +46 (0)70-332 1551 |
    ---------------------------------------------------------------

    <div dir="ltr">Hi Paul<div><br></div><div>Thank you for pointing out the reason why umask 0 is used. I think it is reasonable.</div><div>I think it would be a good thing if the caller could tell the umask to use, or alternatively use different functions.<
    /div><div>But I let other people handle that.</div><div><br></div><div>Your explanation shows that the vulnerability is in pcs only and the generic code is not vulnerable since the intention was not to use it for internal communication without further 
    authentication or similar.</div><div><br></div><div>Cheers</div><div><br></div><div>// Ola</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 10 Sept 2022 at 03:36, Paul Wise &lt;<a href="mailto:pabs@debian.org">pabs@debian.
    org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Fri, 2022-09-09 at 22:41 +0200, Ola Lundqvist wrote:<br>

    &gt; I see that I was not clear what I meant with &quot;in general&quot; :-)<br>

    Woops, sorry for the noise :)<br>

    &gt; Here I found how the generic source code looks like:<br>
    &gt; <a href="https://rubydoc.info/gems/thin/1.3.1/Thin%2FBackends%2FUnixServer:connect" rel="noreferrer" target="_blank">https://rubydoc.info/gems/thin/1.3.1/Thin%2FBackends%2FUnixServer:connect</a><br>
    &gt; <br>
    &gt; You can see the umask(0) there.<br>
    &gt; <br>
    &gt; That is what I think is insecure, not pcs itself.<br>

    Agreed.<br>

    &gt; But I think Thin::Backends::UnixServer#connect is still insecure.<br>

    It looks like the issue was introduced in this pull request:<br>

       <a href="https://github.com/macournoyer/thin/pull/28" rel="noreferrer" target="_blank">https://github.com/macournoyer/thin/pull/28</a><br>

    It sounds like unicorn might have the same issue as thin.<br>

    Looking at the unicorn code, it sets the default umask to 0<br>
    when the umask option is not set, so not quite as bad but still.<br>

    The justification for the default umask of 0 in unicorn is:<br>

       #   Typically UNIX domain sockets are created with more liberal<br>
       #   file permissions than the rest of the application.  By default,<br>    #   we create UNIX domain sockets to be readable and writable by<br>    #   all local users to give them the same accessibility as<br>
       #   locally-bound TCP listeners.<br>

    So the choice of umask 0 is deliberate in unicorn and the thin folks<br>
    copied that choice and dropped the possibility of overriding it,<br>
    since they did&#39;t have an options argument for the function.<br>

    Since UNIX domain sockets are often used for situations that are not<br>
    like localhost TCP sockets, that was probably the wrong choice, but<br>
    the unicorn/thin folks are likely from the web developer community,<br>
    which is mostly focused on HTTP and TCP and often use localhost for<br> development, so it was the right choice within their bubble.<br>

    I feel like the APIs of both thin and unicorn need redesigning so that<br>
    the choice of umask to use must be made by the caller. Then the web<br> developer community can use 0 and others will choose a safe value.<br>

    Really the web developer community shouldn&#39;t use 0 either but I expect<br> that convincing them of that might not be possible.<br>

    I&#39;m not sure how palatable the API change will be to thin/unicorn.<br>

    -- <br>
    bye,<br>
    pabs<br>

    <a href="https://wiki.debian.org/PaulWise" rel="noreferrer" target="_blank">https://wiki.debian.org/PaulWise</a><br>
    </blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><div><font face="courier new, monospace" size="1"> --- Inguza Technology AB --- MSc in Information
    Technology ----</font></div><div><font face="courier new, monospace" size="1">|  </font><a href="mailto:ola@inguza.com" style="font-family:&quot;courier new&quot;,monospace;font-size:x-small" target="_blank">ola@inguza.com</a><span style="font-family:&
    quot;courier new&quot;,monospace;font-size:x-small">                    </span><a href="mailto:opal@debian.org" style="font-family:&quot;courier new&quot;,monospace;font-size:x-small" target="_blank">opal@debian.org</a><span style="font-family:
    &quot;courier new&quot;,monospace;font-size:x-small">            |</span></div><div><font face="courier new, monospace" size="1">|  <a href="http://inguza.com/" target="_blank">http://inguza.com/</a>                Mobile: +46 (0)70-332
    1551 |</font></div><div><font face="courier new, monospace" size="1"> ---------------------------------------------------------------</font></div></div><div><br></div></div></div></div></div></div>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)