Bug 1192284 (CVE-2020-25717)

Summary: VUL-0: CVE-2020-25717: samba: A user on the domain can become root on domain members
Product: [Novell Products] SUSE Security Incidents Reporter: Marcus Meissner <meissner>
Component: IncidentsAssignee: Security Team bot <security-team>
Status: RESOLVED FIXED QA Contact: Security Team bot <security-team>
Severity: Normal    
Priority: P3 - Medium CC: abergmann, gianluca.gabrielli, nopower, rfrohl, samba-maintainers, scabrero
Version: unspecifiedFlags: gianluca.gabrielli: needinfo? (scabrero)
Target Milestone: ---   
Hardware: Other   
OS: Other   
URL: https://smash.suse.de/issue/314128/
Whiteboard: CVSSv3.1:SUSE:CVE-2020-25717:8.1:(AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N)
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Comment 7 Marcus Meissner 2021-11-10 07:59:30 UTC
is public

https://www.samba.org/samba/security/CVE-2020-25717.html


CVE-2020-25717.html:

===========================================================
== Subject:     A user in an AD Domain could become root on
==              domain members
==
== CVE ID#:     CVE-2020-25717
==
== Versions:    All Samba versions since Samba 3.0
==
== Summary:     Samba may map domain users to local users
==              in an undesired way.
===========================================================

===========
Description
===========

Windows Active Directory (AD) domains have by default a feature to
allow users to create computer accounts, controlled by
ms-DS-MachineAccountQuota.

In addition some (presumably trusted) users have the right to create
new users or computers in both Samba and Windows Active Directory
Domains.

These features can be quite dangerous in the wrong hands, as the user
who creates such accounts has broad privileges to not just create them
and set their passwords, but to rename them at a later time with the
only contraint being they may not match an existing samAccountName in
AD.

When Samba as an AD Domain member accepts a Kerberos ticket, it must
map the information found therein to a local UNIX user-id (uid). This
is currently done via the account name in the Active Directory
generated Kerberos Privileged Attribute Certificate (PAC), or the
account name in the ticket (if there is no PAC).

For example, Samba will attempt to find a user "DOMAIN\user" before
falling back to trying to find the user "user".

If the DOMAIN\user lookup can be made to fail, then a privilege
escalation is possible.

The easiest example to illustrate this is if an attacker creates an
account named root (by renaming a MachineAccountQuota based machine
account), and asks for a login without a Kerberos PAC. Between
obtaining the ticket and presenting it to a server, the attacker
renames the user account to a different name. Samba attempts to look
up "DOMAIN\root", which fails (as this no longer exists) and then
falls back to looking up user "root", which will map to the privileged
UNIX uid of 0.

This patch changes Samba to require a PAC (in all scenarios related to
active directory domains) and use the SID and account name
values of the PAC, which means the combination represents the same point
in time. The processing is now similar to as with NTLM based logins.
The SID is unique and non-repeating and so can't be confused with another user.

Additionally, a new parameter has been added "min domain uid" (default
1000), and no matter how we obtain the UNIX uid to use in the process
token (we may eventually read /etc/passwd or similar), by default no
UNIX uid below this value will be accepted.

The patch also removes the fallback from 'DOMAIN\user' to just 'user',
as it dangerous and not needed when nss_winbind is used (even when
'winbind use default domain = yes' is set).

However there are setups which are joined to an active directory
domain just for authentication, but the authorization is handled
without nss_winbind by mapping the domain account to a local user
provided by nss_file, nss_ldap or something similar. NOTE: These
setups won't work anymore without explicitly mapping the users!

For these setups administrators need to use the 'username map' or
'username map script' option in order to map domain users explicitly
to local users, e.g.

  user = DOMAIN\user

Please consult 'man 5 smb.conf' for further details on 'username
map' or 'username map script'. Also note that in the above example '\'
refers to the default value of the 'winbind separator' option.


============
Beyond Samba
============

Samba is almost unique in the Linux/Unix landscape in that it can read
the PAC and make authorisation choices based on the SIDs in the PAC.

Administrators and those responsible for the deployment of other
applications that use Kerberos, and which can only rely on the "cname"
(client name) in the Kerberos ticket should take care not to map these
into the same namespace as system users.

NFS-Ganesha has a mode to map AD domain users via Samba's winbindd.
Use of this mode is encouraged, and (for all NFS servers in AD
domains) the default idmapd.conf "Method = nsswitch" is discouraged.

Likewise special care should be taken in the general configuration of
"auth_to_local" in a krb5.conf as might be used by other services.

==================
Patch Availability
==================

Patches addressing both these issues have been posted to:

    https://www.samba.org/samba/security/

Additionally, Samba 4.15.2, 4.14.10 and 4.13.14 have been issued
as security releases to correct the defect.  Samba administrators are
advised to upgrade to these releases or apply the patch as soon
as possible.

==================
CVSSv3 calculation
==================

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N (8.1)

==========
Workaround
==========

Setting "gensec:require_pac=true" in the smb.conf makes the
DOMAIN\user lookup succeed, due to a cache prime in winbind, provided
nss_winbind is in use and no error paths are hit.

It would be prudent to pre-create disabled users in Active Directory
matching on all privileged names not held in Active Directory, eg

 samba-tool user add root -H ldap://$SERVER -U$USERNAME%$PASSWORD --random-password
 samba-tool user add ubuntu -H ldap://$SERVER -U$USERNAME%$PASSWORD --random-password
 ...

(repeat for eg all system users under 1000 in /etc/passwd or special
 to any other AD-connected services, eg perhaps "admin" for a web-app)

Setting ms-DS-MachineAccountQuota to 0, in the Active Directory domain
is also advised, if possible.

The following settings might be additional mitigations (but they have
not been explicitly verified yet):

1. The use of the 'invalid users' option, note this needs to be
   specified in the [global] section, as well as every share with an
   existing 'invalid users' option, e.g.:

   invalid users = root, ubuntu

2. The usage of the "obey pam restrictions = yes" together with
   something like 'account required pam_succeed_if.so quiet uid >=
   1000' in the pam configuration for "samba", please consult 'man 8
   pam_succeed_if'.

=======
Credits
=======

Originally reported by Andrew Bartlett of Catalyst and the Samba Team.

Patches provided by:
 * Stefan Metzmacher of SerNet and the Samba Team
 * Samuel Cabrero of SuSE and the Samba Team
 * Joseph Sutton of Catalyst and the Samba Team
 * Alexander Bokovoy of Red Hat and the Samba Team
 * Ralph Boehme of SerNet and the Samba Team

Andrew wishes to give much thanks to NetSPI for the blog
"MachineAccountQuota is USEFUL Sometimes: Exploiting One of Active
Directory's Oddest Settings" by Kevin Robertson[1], on which the full
horror of MachineAccountQuota became clear.

[1] https://www.netspi.com/blog/technical/network-penetration-testing/machineaccountquota-is-useful-sometimes/

==========================================================
== Our Code, Our Bugs, Our Responsibility.
== The Samba Team
==========================================================
Comment 8 Swamp Workflow Management 2021-11-10 20:18:57 UTC
openSUSE-SU-2021:3647-1: An update that fixes 8 vulnerabilities is now available.

Category: security (important)
Bug References: 1014440,1192214,1192215,1192246,1192247,1192283,1192284,1192505
CVE References: CVE-2016-2124,CVE-2020-25717,CVE-2020-25718,CVE-2020-25719,CVE-2020-25721,CVE-2020-25722,CVE-2021-23192,CVE-2021-3738
JIRA References: 
Sources used:
openSUSE Leap 15.3 (src):    ldb-2.2.2-3.3.1, samba-4.13.13+git.528.140935f8d6a-3.12.1
Comment 9 Swamp Workflow Management 2021-11-10 20:23:50 UTC
SUSE-SU-2021:3649-1: An update that fixes three vulnerabilities is now available.

Category: security (important)
Bug References: 1014440,1192214,1192284
CVE References: CVE-2016-2124,CVE-2020-25717,CVE-2021-23192
JIRA References: 
Sources used:
SUSE Linux Enterprise Software Development Kit 12-SP5 (src):    samba-4.10.18+git.339.c912385a5e1-3.41.1
SUSE Linux Enterprise Server 12-SP5 (src):    samba-4.10.18+git.339.c912385a5e1-3.41.1
SUSE Linux Enterprise High Availability 12-SP5 (src):    samba-4.10.18+git.339.c912385a5e1-3.41.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 10 Swamp Workflow Management 2021-11-10 20:25:20 UTC
openSUSE-SU-2021:3650-1: An update that fixes three vulnerabilities is now available.

Category: security (important)
Bug References: 1014440,1192214,1192284
CVE References: CVE-2016-2124,CVE-2020-25717,CVE-2021-23192
JIRA References: 
Sources used:
openSUSE Leap 15.3 (src):    samba-4.11.14+git.308.666c63d4eea-4.28.1
Comment 11 Swamp Workflow Management 2021-11-10 20:28:15 UTC
SUSE-SU-2021:3650-1: An update that fixes three vulnerabilities is now available.

Category: security (important)
Bug References: 1014440,1192214,1192284
CVE References: CVE-2016-2124,CVE-2020-25717,CVE-2021-23192
JIRA References: 
Sources used:
SUSE Linux Enterprise Module for Python2 15-SP2 (src):    samba-4.11.14+git.308.666c63d4eea-4.28.1
SUSE Linux Enterprise Module for Basesystem 15-SP2 (src):    samba-4.11.14+git.308.666c63d4eea-4.28.1
SUSE Linux Enterprise High Availability 15-SP2 (src):    samba-4.11.14+git.308.666c63d4eea-4.28.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 12 Swamp Workflow Management 2021-11-10 20:32:58 UTC
SUSE-SU-2021:3647-1: An update that fixes 8 vulnerabilities is now available.

Category: security (important)
Bug References: 1014440,1192214,1192215,1192246,1192247,1192283,1192284,1192505
CVE References: CVE-2016-2124,CVE-2020-25717,CVE-2020-25718,CVE-2020-25719,CVE-2020-25721,CVE-2020-25722,CVE-2021-23192,CVE-2021-3738
JIRA References: 
Sources used:
SUSE MicroOS 5.1 (src):    ldb-2.2.2-3.3.1
SUSE Linux Enterprise Module for Python2 15-SP3 (src):    samba-4.13.13+git.528.140935f8d6a-3.12.1
SUSE Linux Enterprise Module for Basesystem 15-SP3 (src):    ldb-2.2.2-3.3.1, samba-4.13.13+git.528.140935f8d6a-3.12.1
SUSE Linux Enterprise High Availability 15-SP3 (src):    samba-4.13.13+git.528.140935f8d6a-3.12.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 13 Swamp Workflow Management 2021-11-15 11:22:48 UTC
openSUSE-SU-2021:1471-1: An update that fixes three vulnerabilities is now available.

Category: security (important)
Bug References: 1014440,1192214,1192284
CVE References: CVE-2016-2124,CVE-2020-25717,CVE-2021-23192
JIRA References: 
Sources used:
openSUSE Leap 15.2 (src):    samba-4.11.14+git.308.666c63d4eea-lp152.3.28.1
Comment 14 Swamp Workflow Management 2021-11-16 17:21:19 UTC
openSUSE-SU-2021:3674-1: An update that fixes two vulnerabilities is now available.

Category: security (important)
Bug References: 1014440,1192284
CVE References: CVE-2016-2124,CVE-2020-25717
JIRA References: 
Sources used:
openSUSE Leap 15.3 (src):    samba-4.9.5+git.471.5edbe3dcae7-3.57.2
Comment 15 Swamp Workflow Management 2021-11-16 17:24:29 UTC
SUSE-SU-2021:3674-1: An update that fixes two vulnerabilities is now available.

Category: security (important)
Bug References: 1014440,1192284
CVE References: CVE-2016-2124,CVE-2020-25717
JIRA References: 
Sources used:
SUSE Linux Enterprise Server for SAP 15-SP1 (src):    samba-4.9.5+git.471.5edbe3dcae7-3.57.2
SUSE Linux Enterprise Server 15-SP1-LTSS (src):    samba-4.9.5+git.471.5edbe3dcae7-3.57.2
SUSE Linux Enterprise Server 15-SP1-BCL (src):    samba-4.9.5+git.471.5edbe3dcae7-3.57.2
SUSE Linux Enterprise High Performance Computing 15-SP1-LTSS (src):    samba-4.9.5+git.471.5edbe3dcae7-3.57.2
SUSE Linux Enterprise High Performance Computing 15-SP1-ESPOS (src):    samba-4.9.5+git.471.5edbe3dcae7-3.57.2
SUSE Linux Enterprise High Availability 15-SP1 (src):    samba-4.9.5+git.471.5edbe3dcae7-3.57.2
SUSE Enterprise Storage 6 (src):    samba-4.9.5+git.471.5edbe3dcae7-3.57.2
SUSE CaaS Platform 4.0 (src):    samba-4.9.5+git.471.5edbe3dcae7-3.57.2

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 16 Swamp Workflow Management 2021-11-16 17:27:34 UTC
SUSE-SU-2021:3673-1: An update that fixes two vulnerabilities is now available.

Category: security (important)
Bug References: 1014440,1192284
CVE References: CVE-2016-2124,CVE-2020-25717
JIRA References: 
Sources used:
SUSE Linux Enterprise Server 12-SP2-BCL (src):    samba-4.4.2-38.45.2

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 17 Swamp Workflow Management 2021-11-19 20:20:12 UTC
SUSE-SU-2021:3747-1: An update that fixes two vulnerabilities is now available.

Category: security (important)
Bug References: 1014440,1192284
CVE References: CVE-2016-2124,CVE-2020-25717
JIRA References: 
Sources used:
SUSE Linux Enterprise Server for SAP 15 (src):    samba-4.7.11+git.352.41e30c5a0f7-4.57.1
SUSE Linux Enterprise Server 15-LTSS (src):    samba-4.7.11+git.352.41e30c5a0f7-4.57.1
SUSE Linux Enterprise High Performance Computing 15-LTSS (src):    samba-4.7.11+git.352.41e30c5a0f7-4.57.1
SUSE Linux Enterprise High Performance Computing 15-ESPOS (src):    samba-4.7.11+git.352.41e30c5a0f7-4.57.1
SUSE Linux Enterprise High Availability 15 (src):    samba-4.7.11+git.352.41e30c5a0f7-4.57.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 18 Swamp Workflow Management 2021-11-19 20:23:19 UTC
SUSE-SU-2021:3746-1: An update that fixes two vulnerabilities is now available.

Category: security (important)
Bug References: 1014440,1192284
CVE References: CVE-2016-2124,CVE-2020-25717
JIRA References: 
Sources used:
SUSE OpenStack Cloud Crowbar 9 (src):    samba-4.6.16+git.307.b3899d08cc6-3.64.2
SUSE OpenStack Cloud Crowbar 8 (src):    samba-4.6.16+git.307.b3899d08cc6-3.64.2
SUSE OpenStack Cloud 9 (src):    samba-4.6.16+git.307.b3899d08cc6-3.64.2
SUSE OpenStack Cloud 8 (src):    samba-4.6.16+git.307.b3899d08cc6-3.64.2
SUSE Linux Enterprise Server for SAP 12-SP4 (src):    samba-4.6.16+git.307.b3899d08cc6-3.64.2
SUSE Linux Enterprise Server for SAP 12-SP3 (src):    samba-4.6.16+git.307.b3899d08cc6-3.64.2
SUSE Linux Enterprise Server 12-SP4-LTSS (src):    samba-4.6.16+git.307.b3899d08cc6-3.64.2
SUSE Linux Enterprise Server 12-SP3-LTSS (src):    samba-4.6.16+git.307.b3899d08cc6-3.64.2
SUSE Linux Enterprise Server 12-SP3-BCL (src):    samba-4.6.16+git.307.b3899d08cc6-3.64.2
SUSE Linux Enterprise High Availability 12-SP4 (src):    samba-4.6.16+git.307.b3899d08cc6-3.64.2
SUSE Linux Enterprise High Availability 12-SP3 (src):    samba-4.6.16+git.307.b3899d08cc6-3.64.2
HPE Helion Openstack 8 (src):    samba-4.6.16+git.307.b3899d08cc6-3.64.2

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 20 Robert Frohl 2021-12-13 08:14:21 UTC
all done, closing
Comment 22 Swamp Workflow Management 2022-02-10 17:18:51 UTC
SUSE-SU-2022:0361-1: An update that solves 11 vulnerabilities, contains one feature and has two fixes is now available.

Category: security (critical)
Bug References: 1014440,1188727,1189017,1189875,1192214,1192215,1192246,1192247,1192283,1192284,1192505,1192849,1194859
CVE References: CVE-2016-2124,CVE-2020-17049,CVE-2020-25717,CVE-2020-25718,CVE-2020-25719,CVE-2020-25721,CVE-2020-25722,CVE-2021-20254,CVE-2021-23192,CVE-2021-3738,CVE-2021-44142
JIRA References: SLE-18456
Sources used:
SUSE Enterprise Storage 7 (src):    ldb-2.2.2-4.6.1, samba-4.13.13+git.545.5897c2d94f3-3.12.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 26 Samuel Cabrero 2022-03-18 12:01:31 UTC
The request for SLE 11 SP1 was accepted and queued for the next maintenance release. Closing.
Comment 27 Gianluca Gabrielli 2022-03-21 09:52:55 UTC
Hi Samuel,

please never close security-related issue yourself, instead reassign them back to security-team@suse.de