]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
3 years agoCVE-2020-25722 pytest: test sAMAccountName/userPrincipalName over ldap
Douglas Bagnall [Mon, 13 Sep 2021 02:15:09 +0000 (14:15 +1200)] 
CVE-2020-25722 pytest: test sAMAccountName/userPrincipalName over ldap

Because the sam account name + the dns host name is used as the
default user principal name, we need to check for collisions between
these. Fixes are coming in upcoming patches.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14564

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25722 blackbox/upgrades tests: ignore SPN for ldapcmp
Douglas Bagnall [Thu, 28 Oct 2021 00:07:01 +0000 (13:07 +1300)] 
CVE-2020-25722 blackbox/upgrades tests: ignore SPN for ldapcmp

We need to have the SPNs there before someone else nabs them, which
makes the re-provisioned old releases different from the reference
versions that we keep for this comparison.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14564

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25722 s4/provision: add host/ SPNs at the start
Douglas Bagnall [Wed, 27 Oct 2021 20:45:36 +0000 (09:45 +1300)] 
CVE-2020-25722 s4/provision: add host/ SPNs at the start

There are two reasons for this. Firstly, leaving SPNs unclaimed is
dangerous, as someone else could grab them first. Secondly, in some
circumstances (self join) we try to add a DNS/ SPN a little bit later
in provision. Under the rules we are introducing for CVE-2020-25722,
this will make our later attempts to add HOST/ fail.

This causes a few errors in samba4.blackbox.dbcheck.* tests, which
assert that revivified old domains match stored reference versions.
Now they don't, because they have servicePrincipalNames.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14564

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25722 tests: blackbox samba-tool spn non-admin test
Douglas Bagnall [Wed, 1 Sep 2021 06:35:02 +0000 (18:35 +1200)] 
CVE-2020-25722 tests: blackbox samba-tool spn non-admin test

It is soon going to be impossible to add duplicate SPNs (short of
going behind DSDB's back on the local filesystem). Our test of adding
SPNs on non-admin users doubled as the test for adding a duplicate (using
--force). As --force is gone, we add these tests on Guest after the SPN
on Administrator is gone.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14564

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25722 samba-tool spn add: remove --force option
Douglas Bagnall [Thu, 26 Aug 2021 23:36:42 +0000 (11:36 +1200)] 
CVE-2020-25722 samba-tool spn add: remove --force option

This did not actually *force* the creation of a duplicate SPN, it just
ignored the client-side check for the existing copy. Soon we are going
to enforce SPN uniqueness on the server side, and this --force will not
work. This will make the --force test fail, and if that tests fail, so
will others that depend the duplicate values. So we remove those tests.

It is wrong-headed to try to make duplicate SPNs in any case, which is
probably why there is no sign of anyone ever having used this option.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14564

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25722 samba-tool spn: accept -H for database url
Douglas Bagnall [Wed, 28 Jul 2021 05:38:50 +0000 (05:38 +0000)] 
CVE-2020-25722 samba-tool spn: accept -H for database url

Following the convention and making testing easier

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14564

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25722 s4/cracknames: lookup_spn_alias doesn't need krb5 context
Douglas Bagnall [Tue, 10 Aug 2021 23:02:36 +0000 (23:02 +0000)] 
CVE-2020-25722 s4/cracknames: lookup_spn_alias doesn't need krb5 context

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14564

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25722 s4/dsdb/cracknames: always free tmp_ctx in spn_alias
Douglas Bagnall [Wed, 11 Aug 2021 04:56:07 +0000 (16:56 +1200)] 
CVE-2020-25722 s4/dsdb/cracknames: always free tmp_ctx in spn_alias

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14564

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25722 pytest: assertRaisesLdbError invents a message if you're lazy
Douglas Bagnall [Sun, 24 Oct 2021 02:18:05 +0000 (15:18 +1300)] 
CVE-2020-25722 pytest: assertRaisesLdbError invents a message if you're lazy

This makes it easier to convert tests that don't have good messages.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14564

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25722 pytests: add reverse lookup dict for LDB error codes
Douglas Bagnall [Sun, 3 Oct 2021 23:56:42 +0000 (12:56 +1300)] 
CVE-2020-25722 pytests: add reverse lookup dict for LDB error codes

You can give ldb_err() it a number, an LdbError, or a sequence of
numbers, and it will return the corresponding strings. Examples:

ldb_err(68)       # "LDB_ERR_ENTRY_ALREADY_EXISTS"
LDB_ERR_LUT[68]   # "LDB_ERR_ENTRY_ALREADY_EXISTS"

expected = (ldb.ERR_INSUFFICIENT_ACCESS_RIGHTS,
            ldb.ERR_INVALID_CREDENTIALS)
try:
    foo()
except ldb.LdbError as e:
    self.fail(f"got {ldb_err(e)}, expected one of {ldb_err(expected)}")

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14564

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25722 Check for all errors from acl_check_extended_right() in acl_check_spn()
Andrew Bartlett [Mon, 1 Nov 2021 04:21:16 +0000 (17:21 +1300)] 
CVE-2020-25722 Check for all errors from acl_check_extended_right() in acl_check_spn()

We should not fail open on error.

BUG:  https://bugzilla.samba.org/show_bug.cgi?id=14876
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
3 years agoCVE-2020-25722 Check all elements in acl_check_spn() not just the first one
Andrew Bartlett [Mon, 1 Nov 2021 04:19:29 +0000 (17:19 +1300)] 
CVE-2020-25722 Check all elements in acl_check_spn() not just the first one

Thankfully we are aleady in a loop over all the message elements in
acl_modify() so this is an easy and safe change to make.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14876
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
3 years agoCVE-2020-25722: s4-acl: Make sure Control Access Rights honor the Applies-to attribute
Nadezhda Ivanova [Mon, 18 Oct 2021 11:27:59 +0000 (14:27 +0300)] 
CVE-2020-25722: s4-acl: Make sure Control Access Rights honor the Applies-to attribute

Validate Writes and Control Access Rights only grant access if the
object is of the type listed in the Right's appliesTo attribute. For
example, even though a Validated-SPN access may be granted to a user
object in the SD, it should only pass if the object is of class
computer This patch enforces the appliesTo attribute classes for
access checks from within the ldb stack.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14832

Signed-off-by: Nadezhda Ivanova <nivanova@symas.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25722: s4-acl: test Control Access Rights honor the Applies-to attribute
Nadezhda Ivanova [Mon, 25 Oct 2021 11:54:56 +0000 (14:54 +0300)] 
CVE-2020-25722: s4-acl: test Control Access Rights honor the Applies-to attribute

Validate Writes and Control Access Rights should only grant access if the
object is of the type listed in the Right's appliesTo attribute.
Tests to verify this behavior

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14832

Signed-off-by: Nadezhda Ivanova <nivanova@symas.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25722 s4:dsdb:tests: Add missing self.fail() calls
Joseph Sutton [Fri, 8 Oct 2021 02:49:31 +0000 (15:49 +1300)] 
CVE-2020-25722 s4:dsdb:tests: Add missing self.fail() calls

Without these calls the tests could pass if an expected error did not
occur.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14832

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
[abartlet@samba.org Included in backport as changing ACLs while
 ACL tests are not checking for unexpected success would be bad]

3 years agoCVE-2020-25722 Add test for SPN deletion followed by addition
Joseph Sutton [Mon, 18 Oct 2021 01:07:41 +0000 (14:07 +1300)] 
CVE-2020-25722 Add test for SPN deletion followed by addition

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14876

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
[abartlet@samba.org Removed transaction hooks, these do nothing over
 remote LDAP]

3 years agoCVE-2020-25717: s3:auth: simplify make_session_info_krb5() by removing unused arguments
Stefan Metzmacher [Fri, 8 Oct 2021 16:03:04 +0000 (18:03 +0200)] 
CVE-2020-25717: s3:auth: simplify make_session_info_krb5() by removing unused arguments

This is only ever be called in standalone mode with an MIT realm,
so we don't have a PAC/info3 structure.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s3:auth: simplify get_user_from_kerberos_info() by removing the unuse...
Stefan Metzmacher [Fri, 8 Oct 2021 15:59:59 +0000 (17:59 +0200)] 
CVE-2020-25717: s3:auth: simplify get_user_from_kerberos_info() by removing the unused logon_info argument

This code is only every called in standalone mode on a MIT realm,
it means we never have a PAC and we also don't have winbindd arround.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s3:auth: let auth3_generate_session_info_pac() reject a PAC in standa...
Stefan Metzmacher [Tue, 5 Oct 2021 16:12:49 +0000 (18:12 +0200)] 
CVE-2020-25717: s3:auth: let auth3_generate_session_info_pac() reject a PAC in standalone mode

We should be strict in standalone mode, that we only support MIT realms
without a PAC in order to keep the code sane.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: selftest: configure 'ktest' env with winbindd and idmap_autorid
Stefan Metzmacher [Tue, 5 Oct 2021 15:14:01 +0000 (17:14 +0200)] 
CVE-2020-25717: selftest: configure 'ktest' env with winbindd and idmap_autorid

The 'ktest' environment was/is designed to test kerberos in an active
directory member setup. It was created at a time we wanted to test
smbd/winbindd with kerberos without having the source4 ad dc available.

This still applies to testing the build with system krb5 libraries
but without relying on a running ad dc.

As a domain member setup requires a running winbindd, we should test it
that way, in order to reflect a valid setup.

As a side effect it provides a way to demonstrate that we can accept
smb connections authenticated via kerberos, but no connection to
a domain controller! In order get this working offline, we need an
idmap backend with ID_TYPE_BOTH support, so we use 'autorid', which
should be the default choice.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14646
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s3:auth: let auth3_generate_session_info_pac() delegate everything...
Stefan Metzmacher [Mon, 4 Oct 2021 17:42:20 +0000 (19:42 +0200)] 
CVE-2020-25717: s3:auth: let auth3_generate_session_info_pac() delegate everything to make_server_info_wbcAuthUserInfo()

This consolidates the code paths used for NTLMSSP and Kerberos!

I checked what we were already doing for NTLMSSP, which is this:

a) source3/auth/auth_winbind.c calls wbcAuthenticateUserEx()
b) as a domain member we require a valid response from winbindd,
   otherwise we'll return NT_STATUS_NO_LOGON_SERVERS
c) we call make_server_info_wbcAuthUserInfo(), which internally
   calls make_server_info_info3()
d) auth_check_ntlm_password() calls
   smb_pam_accountcheck(unix_username, rhost), where rhost
   is only an ipv4 or ipv6 address (without reverse dns lookup)
e) from auth3_check_password_send/auth3_check_password_recv()
   server_returned_info will be passed to auth3_generate_session_info(),
   triggered by gensec_session_info(), which means we'll call into
   create_local_token() in order to transform auth_serversupplied_info
   into auth_session_info.

For Kerberos gensec_session_info() will call
auth3_generate_session_info_pac() via the gensec_generate_session_info_pac()
helper function. The current logic is this:

a) gensec_generate_session_info_pac() is the function that
   evaluates the 'gensec:require_pac', which defaulted to 'no'
   before.
b) auth3_generate_session_info_pac() called
   wbcAuthenticateUserEx() in order to pass the PAC blob
   to winbindd, but only to prime its cache, e.g. netsamlogon cache
   and others. Most failures were just ignored.
c) If the PAC blob is available, it extracted the PAC_LOGON_INFO
   from it.
d) Then we called the horrible get_user_from_kerberos_info() function:
   - It uses a first part of the tickets principal name (before the @)
     as username and combines that with the 'logon_info->base.logon_domain'
     if the logon_info (PAC) is present.
   - As a fallback without a PAC it's tries to ask winbindd for a mapping
     from realm to netbios domain name.
   - Finally is falls back to using the realm as netbios domain name
   With this information is builds 'userdomain+winbind_separator+useraccount'
   and calls map_username() followed by smb_getpwnam() with create=true,
   Note this is similar to the make_server_info_info3() => check_account()
   => smb_getpwnam() logic under 3.
   - It also calls smb_pam_accountcheck(), but may pass the reverse DNS lookup name
     instead of the ip address as rhost.
   - It does some MAP_TO_GUEST_ON_BAD_UID logic and auto creates the
     guest account.
e) We called create_info3_from_pac_logon_info()
f) make_session_info_krb5() calls gets called and triggers this:
   - If get_user_from_kerberos_info() mapped to guest, it calls
     make_server_info_guest()
   - If create_info3_from_pac_logon_info() created a info3 from logon_info,
     it calls make_server_info_info3()
   - Without a PAC it tries pdb_getsampwnam()/make_server_info_sam() with
     a fallback to make_server_info_pw()
   From there it calls create_local_token()

I tried to change auth3_generate_session_info_pac() to behave similar
to auth_winbind.c together with auth3_generate_session_info() as
a domain member, as we now rely on a PAC:

a) As domain member we require a PAC and always call wbcAuthenticateUserEx()
   and require a valid response!
b) we call make_server_info_wbcAuthUserInfo(), which internally
   calls make_server_info_info3(). Note make_server_info_info3()
   handles MAP_TO_GUEST_ON_BAD_UID and make_server_info_guest()
   internally.
c) Similar to auth_check_ntlm_password() we now call
   smb_pam_accountcheck(unix_username, rhost), where rhost
   is only an ipv4 or ipv6 address (without reverse dns lookup)
d) From there it calls create_local_token()

As standalone server (in an MIT realm) we continue
with the already existing code logic, which works without a PAC:
a) we keep smb_getpwnam() with create=true logic as it
   also requires an explicit 'add user script' option.
b) In the following commits we assert that there's
   actually no PAC in this mode, which means we can
   remove unused and confusing code.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14646
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s3:ntlm_auth: let ntlm_auth_generate_session_info_pac() base the...
Stefan Metzmacher [Tue, 21 Sep 2021 10:44:01 +0000 (12:44 +0200)] 
CVE-2020-25717: s3:ntlm_auth: let ntlm_auth_generate_session_info_pac() base the name on the PAC LOGON_INFO only

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14801
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s3:ntlm_auth: fix memory leaks in ntlm_auth_generate_session_info_pac()
Stefan Metzmacher [Tue, 21 Sep 2021 10:27:28 +0000 (12:27 +0200)] 
CVE-2020-25717: s3:ntlm_auth: fix memory leaks in ntlm_auth_generate_session_info_pac()

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14801
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25719 CVE-2020-25717: s4:auth: remove unused auth_generate_session_info_prin...
Stefan Metzmacher [Mon, 11 Oct 2021 21:17:19 +0000 (23:17 +0200)] 
CVE-2020-25719 CVE-2020-25717: s4:auth: remove unused auth_generate_session_info_principal()

We'll require a PAC at the main gensec layer already.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14801
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25719 CVE-2020-25717: auth/gensec: always require a PAC in domain mode ...
Stefan Metzmacher [Tue, 5 Oct 2021 16:11:57 +0000 (18:11 +0200)] 
CVE-2020-25719 CVE-2020-25717: auth/gensec: always require a PAC in domain mode (DC or member)

AD domains always provide a PAC unless UF_NO_AUTH_DATA_REQUIRED is set
on the service account, which can only be explicitly configured,
but that's an invalid configuration!

We still try to support standalone servers in an MIT realm,
as legacy setup.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14801
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
[jsutton@samba.org Removed knownfail entries]

3 years agoCVE-2020-25717: Add FreeIPA domain controller role
Alexander Bokovoy [Wed, 11 Nov 2020 16:50:45 +0000 (18:50 +0200)] 
CVE-2020-25717: Add FreeIPA domain controller role

As we want to reduce use of 'classic domain controller' role but FreeIPA
relies on it internally, add a separate role to mark FreeIPA domain
controller role.

It means that role won't result in ROLE_STANDALONE.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14801
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Alexander Bokovoy <ab@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s3:auth: don't let create_local_token depend on !winbind_ping()
Stefan Metzmacher [Mon, 4 Oct 2021 16:03:55 +0000 (18:03 +0200)] 
CVE-2020-25717: s3:auth: don't let create_local_token depend on !winbind_ping()

We always require a running winbindd on a domain member, so
we should better fail a request instead of silently alter
the behaviour, which results in a different unix token, just
because winbindd might be restarted.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14801
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s3:lib: add lp_allow_trusted_domains() logic to is_allowed_domain()
Stefan Metzmacher [Tue, 21 Sep 2021 11:13:52 +0000 (13:13 +0200)] 
CVE-2020-25717: s3:lib: add lp_allow_trusted_domains() logic to is_allowed_domain()

is_allowed_domain() is a central place we already use to
trigger NT_STATUS_AUTHENTICATION_FIREWALL_FAILED, so
we can add additional logic there.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14801
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s3:auth: remove fallbacks in smb_getpwnam()
Ralph Boehme [Fri, 8 Oct 2021 10:33:16 +0000 (12:33 +0200)] 
CVE-2020-25717: s3:auth: remove fallbacks in smb_getpwnam()

So far we tried getpwnam("DOMAIN\account") first and
always did a fallback to getpwnam("account") completely
ignoring the domain part, this just causes problems
as we mix "DOMAIN1\account", "DOMAIN2\account",
and "account"!

As we require a running winbindd for domain member setups
we should no longer do a fallback to just "account" for
users served by winbindd!

For users of the local SAM don't use this code path,
as check_sam_security() doesn't call check_account().

The only case where smb_getpwnam("account") happens is
when map_username() via ("username map [script]")  mapped
"DOMAIN\account" to something without '\', but that is
explicitly desired by the admin.

Note: use 'git show -w'

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14801
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Ralph Boehme <slow@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s3:auth: no longer let check_account() autocreate local users
Stefan Metzmacher [Fri, 8 Oct 2021 16:08:20 +0000 (18:08 +0200)] 
CVE-2020-25717: s3:auth: no longer let check_account() autocreate local users

So far we autocreated local user accounts based on just the
account_name (just ignoring any domain part).

This only happens via a possible 'add user script',
which is not typically defined on domain members
and on NT4 DCs local users already exist in the
local passdb anyway.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14801

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s3:auth: we should not try to autocreate the guest account
Stefan Metzmacher [Fri, 8 Oct 2021 15:40:30 +0000 (17:40 +0200)] 
CVE-2020-25717: s3:auth: we should not try to autocreate the guest account

We should avoid autocreation of users as much as possible.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14801
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s3:auth: Check minimum domain uid
Samuel Cabrero [Tue, 28 Sep 2021 08:45:11 +0000 (10:45 +0200)] 
CVE-2020-25717: s3:auth: Check minimum domain uid

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14801
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
[abartlet@samba.org Removed knownfail on advice from metze]

3 years agoCVE-2020-25717: s3:auth: let auth3_generate_session_info_pac() forward the low level...
Stefan Metzmacher [Fri, 8 Oct 2021 17:57:18 +0000 (19:57 +0200)] 
CVE-2020-25717: s3:auth: let auth3_generate_session_info_pac() forward the low level errors

Mapping everything to ACCESS_DENIED makes it hard to debug problems,
which may happen because of our more restrictive behaviour in future.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14801
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: selftest: Add a test for the new 'min domain uid' parameter
Samuel Cabrero [Tue, 5 Oct 2021 14:56:06 +0000 (16:56 +0200)] 
CVE-2020-25717: selftest: Add a test for the new 'min domain uid' parameter

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14801
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
[abartlet@samba.org Fixed knowfail per instruction from metze]

3 years agoCVE-2020-25717: selftest: Add ad_member_no_nss_wb environment
Samuel Cabrero [Tue, 5 Oct 2021 10:31:29 +0000 (12:31 +0200)] 
CVE-2020-25717: selftest: Add ad_member_no_nss_wb environment

This environment creates an AD member that doesn't have
'nss_winbind' configured, while winbindd is still started.

For testing we map a DOMAIN\root user to the local root
account and unix token of the local root user.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14801
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
[abartlet@samba.org backported to Samba 4.14 without offline
 tests in Samba3.pm]

3 years agoCVE-2020-25717: loadparm: Add new parameter "min domain uid"
Samuel Cabrero [Tue, 28 Sep 2021 08:43:40 +0000 (10:43 +0200)] 
CVE-2020-25717: loadparm: Add new parameter "min domain uid"

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14801
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
[abartlet@samba.org Backported from master/4.15 due to
 conflicts with other new parameters]

3 years agoCVE-2020-25717: auth/ntlmssp: start with authoritative = 1
Stefan Metzmacher [Tue, 26 Oct 2021 15:42:41 +0000 (17:42 +0200)] 
CVE-2020-25717: auth/ntlmssp: start with authoritative = 1

This is not strictly needed, but makes it easier to audit
that we don't miss important places.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s3:auth: start with authoritative = 1
Stefan Metzmacher [Tue, 26 Oct 2021 15:42:41 +0000 (17:42 +0200)] 
CVE-2020-25717: s3:auth: start with authoritative = 1

This is not strictly needed, but makes it easier to audit
that we don't miss important places.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s3:rpcclient: start with authoritative = 1
Stefan Metzmacher [Tue, 26 Oct 2021 15:42:41 +0000 (17:42 +0200)] 
CVE-2020-25717: s3:rpcclient: start with authoritative = 1

This is not strictly needed, but makes it easier to audit
that we don't miss important places.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s3:torture: start with authoritative = 1
Stefan Metzmacher [Tue, 26 Oct 2021 15:42:41 +0000 (17:42 +0200)] 
CVE-2020-25717: s3:torture: start with authoritative = 1

This is not strictly needed, but makes it easier to audit
that we don't miss important places.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s3:ntlm_auth: start with authoritative = 1
Stefan Metzmacher [Tue, 26 Oct 2021 15:42:41 +0000 (17:42 +0200)] 
CVE-2020-25717: s3:ntlm_auth: start with authoritative = 1

This is not strictly needed, but makes it easier to audit
that we don't miss important places.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s4:auth_simple: start with authoritative = 1
Stefan Metzmacher [Tue, 26 Oct 2021 15:42:41 +0000 (17:42 +0200)] 
CVE-2020-25717: s4:auth_simple: start with authoritative = 1

This is not strictly needed, but makes it easier to audit
that we don't miss important places.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s4:smb_server: start with authoritative = 1
Stefan Metzmacher [Tue, 26 Oct 2021 15:42:41 +0000 (17:42 +0200)] 
CVE-2020-25717: s4:smb_server: start with authoritative = 1

This is not strictly needed, but makes it easier to audit
that we don't miss important places.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s4:torture: start with authoritative = 1
Stefan Metzmacher [Tue, 26 Oct 2021 15:42:41 +0000 (17:42 +0200)] 
CVE-2020-25717: s4:torture: start with authoritative = 1

This is not strictly needed, but makes it easier to audit
that we don't miss important places.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s4:auth/ntlm: make sure auth_check_password() defaults to r->out...
Stefan Metzmacher [Mon, 4 Oct 2021 15:29:34 +0000 (17:29 +0200)] 
CVE-2020-25717: s4:auth/ntlm: make sure auth_check_password() defaults to r->out.authoritative = true

We need to make sure that temporary failures don't trigger a fallback
to the local SAM that silently ignores the domain name part for users.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25717: s3:winbindd: make sure we default to r->out.authoritative = true
Stefan Metzmacher [Mon, 4 Oct 2021 15:29:34 +0000 (17:29 +0200)] 
CVE-2020-25717: s3:winbindd: make sure we default to r->out.authoritative = true

We need to make sure that temporary failures don't trigger a fallback
to the local SAM that silently ignores the domain name part for users.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25719 CVE-2020-25717 tests/krb5: Adapt tests for connecting without a PAC...
Joseph Sutton [Thu, 28 Oct 2021 21:27:41 +0000 (10:27 +1300)] 
CVE-2020-25719 CVE-2020-25717 tests/krb5: Adapt tests for connecting without a PAC to new error codes

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14799
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14561
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25719 CVE-2020-25717: selftest: remove "gensec:require_pac" settings
Stefan Metzmacher [Fri, 22 Oct 2021 14:20:36 +0000 (16:20 +0200)] 
CVE-2020-25719 CVE-2020-25717: selftest: remove "gensec:require_pac" settings

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14799
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14561

[jsutton@samba.org Added knownfail entries]

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25719 CVE-2020-25717 tests/krb5: Add tests for connecting to services anonym...
Stefan Metzmacher [Tue, 24 Aug 2021 15:11:24 +0000 (17:11 +0200)] 
CVE-2020-25719 CVE-2020-25717 tests/krb5: Add tests for connecting to services anonymously and without a PAC

At the end of the patchset we assume NT_STATUS_NO_IMPERSONATION_TOKEN if
no PAC is available.

For now we want to look for ACCESS_DENIED as this allows
the test to pass (showing that gensec:require_pac = true
is a useful partial mitigation).

This will also help others doing backports that do not
take the full patch set.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14801
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14799
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14561
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14556

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25721 tests/krb5: Add tests for extended PAC_UPN_DNS_INFO PAC buffer
Joseph Sutton [Thu, 21 Oct 2021 03:46:56 +0000 (16:46 +1300)] 
CVE-2020-25721 tests/krb5: Add tests for extended PAC_UPN_DNS_INFO PAC buffer

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14835

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25719 tests/krb5: Add tests for including authdata without a PAC
Joseph Sutton [Thu, 28 Oct 2021 03:20:07 +0000 (16:20 +1300)] 
CVE-2020-25719 tests/krb5: Add tests for including authdata without a PAC

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14561

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25718 tests/krb5: Add tests for RODC-printed and invalid TGTs
Joseph Sutton [Wed, 20 Oct 2021 22:45:23 +0000 (11:45 +1300)] 
CVE-2020-25718 tests/krb5: Add tests for RODC-printed and invalid TGTs

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14558

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25719 tests/krb5: Add principal aliasing test
Joseph Sutton [Tue, 19 Oct 2021 07:02:45 +0000 (20:02 +1300)] 
CVE-2020-25719 tests/krb5: Add principal aliasing test

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14686

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25719 tests/krb5: Add a test for making an S4U2Self request without a PAC
Joseph Sutton [Tue, 19 Oct 2021 01:39:36 +0000 (14:39 +1300)] 
CVE-2020-25719 tests/krb5: Add a test for making an S4U2Self request without a PAC

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14686

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25719 tests/krb5: Add tests for requiring and issuing a PAC
Joseph Sutton [Mon, 18 Oct 2021 02:02:39 +0000 (15:02 +1300)] 
CVE-2020-25719 tests/krb5: Add tests for requiring and issuing a PAC

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14561

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25721 ndrdump: Add tests for PAC with UPN_DNS_INFO
Joseph Sutton [Wed, 13 Oct 2021 03:07:09 +0000 (16:07 +1300)] 
CVE-2020-25721 ndrdump: Add tests for PAC with UPN_DNS_INFO

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14835

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25722 tests/krb5: Add KDC tests for 3-part SPNs
Joseph Sutton [Thu, 21 Oct 2021 02:45:00 +0000 (15:45 +1300)] 
CVE-2020-25722 tests/krb5: Add KDC tests for 3-part SPNs

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14776

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25719 CVE-2020-25717 tests/krb5: Allow create_ccache_with_user() to return...
Joseph Sutton [Thu, 21 Oct 2021 22:37:37 +0000 (11:37 +1300)] 
CVE-2020-25719 CVE-2020-25717 tests/krb5: Allow create_ccache_with_user() to return a ticket without a PAC

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14799
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14561

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25719 CVE-2020-25717 tests/krb5: Refactor create_ccache_with_user() to take...
Joseph Sutton [Thu, 21 Oct 2021 22:37:31 +0000 (11:37 +1300)] 
CVE-2020-25719 CVE-2020-25717 tests/krb5: Refactor create_ccache_with_user() to take credentials of target service

This allows us to use get_tgt() and get_service_ticket() to obtain
tickets, which simplifies the logic.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14799
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14561

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25721 tests/krb5: Check PAC buffer types when STRICT_CHECKING=0
Joseph Sutton [Thu, 21 Oct 2021 03:46:23 +0000 (16:46 +1300)] 
CVE-2020-25721 tests/krb5: Check PAC buffer types when STRICT_CHECKING=0

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14835

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoMS CVE-2020-17049 tests/krb5: Allow tests to pass if ticket signature checksum type...
Joseph Sutton [Wed, 20 Oct 2021 02:48:20 +0000 (15:48 +1300)] 
MS CVE-2020-17049 tests/krb5: Allow tests to pass if ticket signature checksum type is wrong

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14642

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25719 tests/krb5: Add method to get unique username for test accounts
Joseph Sutton [Tue, 19 Oct 2021 02:02:10 +0000 (15:02 +1300)] 
CVE-2020-25719 tests/krb5: Add method to get unique username for test accounts

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14686

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25719 tests/krb5: Add is_tgt() helper method
Joseph Sutton [Thu, 30 Sep 2021 03:53:22 +0000 (16:53 +1300)] 
CVE-2020-25719 tests/krb5: Add is_tgt() helper method

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14686

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25722 tests/krb5: Allow creating server accounts
Joseph Sutton [Fri, 8 Oct 2021 02:40:09 +0000 (15:40 +1300)] 
CVE-2020-25722 tests/krb5: Allow creating server accounts

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14776

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25719 CVE-2020-25717 tests/krb5: Add pac_request parameter to get_service_ti...
Joseph Sutton [Mon, 18 Oct 2021 02:00:38 +0000 (15:00 +1300)] 
CVE-2020-25719 CVE-2020-25717 tests/krb5: Add pac_request parameter to get_service_ticket()

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14799
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14561

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25719 CVE-2020-25717 tests/krb5: Modify get_service_ticket() to use _generic...
Joseph Sutton [Mon, 18 Oct 2021 01:59:01 +0000 (14:59 +1300)] 
CVE-2020-25719 CVE-2020-25717 tests/krb5: Modify get_service_ticket() to use _generic_kdc_exchange()

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14799
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14561

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25718 tests/krb5: Allow tests accounts to replicate to RODC
Joseph Sutton [Wed, 20 Oct 2021 02:48:35 +0000 (15:48 +1300)] 
CVE-2020-25718 tests/krb5: Allow tests accounts to replicate to RODC

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14558

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25721 krb5pac: Add new buffers for samAccountName and objectSID
Andrew Bartlett [Sun, 26 Sep 2021 22:20:19 +0000 (11:20 +1300)] 
CVE-2020-25721 krb5pac: Add new buffers for samAccountName and objectSID

These appear when PAC_UPN_DNS_FLAG_HAS_SAM_NAME_AND_SID is set.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14835

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
3 years agoCVE-2020-25722 selftest/user_account_control: more work to cope with UAC/objectclass...
Andrew Bartlett [Fri, 22 Oct 2021 10:41:23 +0000 (23:41 +1300)] 
CVE-2020-25722 selftest/user_account_control: more work to cope with UAC/objectclass defaults and lock

This new restriction breaks a large number of assumptions in the tests, like
that you can remove some UF_ flags, because it turns out doing so will
make the 'computer' a 'user' again, and this will fail.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 selftest/user_account_control: Allow a broader set of possible errors
Andrew Bartlett [Fri, 22 Oct 2021 09:54:52 +0000 (22:54 +1300)] 
CVE-2020-25722 selftest/user_account_control: Allow a broader set of possible errors

This favors a test that confirms we got an error over getting exactly
the right error, at least for now.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 selftest: Allow self.assertRaisesLdbError() to take a list of errors...
Andrew Bartlett [Fri, 22 Oct 2021 09:40:06 +0000 (22:40 +1300)] 
CVE-2020-25722 selftest: Allow self.assertRaisesLdbError() to take a list of errors to match with

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 selftest: adapt ldap.py/sam.py test_all tests to new default computer...
Andrew Bartlett [Thu, 21 Oct 2021 02:42:46 +0000 (15:42 +1300)] 
CVE-2020-25722 selftest: adapt ldap.py/sam.py test_all tests to new default computer behaviour

Objects of objectclass computer are computers by default now and this changes
the sAMAccountType and primaryGroupID as well as userAccountControl

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 selftest: Adapt sam.py test to userAccountControl/objectclass restrictions
Andrew Bartlett [Thu, 21 Oct 2021 02:19:19 +0000 (15:19 +1300)] 
CVE-2020-25722 selftest: Adapt sam.py test to userAccountControl/objectclass restrictions

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 selftest: New objects of objectclass=computer are workstations by...
Andrew Bartlett [Thu, 21 Oct 2021 02:14:28 +0000 (15:14 +1300)] 
CVE-2020-25722 selftest: New objects of objectclass=computer are workstations by default now

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 selftest: Adjust sam.py test_userAccountControl_computer_add_trust...
Andrew Bartlett [Thu, 21 Oct 2021 02:06:14 +0000 (15:06 +1300)] 
CVE-2020-25722 selftest: Adjust sam.py test_userAccountControl_computer_add_trust to new reality

We now enforce that a trust account must be a user.

These can not be added over LDAP anyway, and our C
code in the RPC server gets this right in any case.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 selftest: Split test_userAccountControl into unit tests
Andrew Bartlett [Thu, 21 Oct 2021 01:03:05 +0000 (14:03 +1300)] 
CVE-2020-25722 selftest: Split test_userAccountControl into unit tests

The parts that create and delete a single object can be
safely split out into an individual test.

At this point the parts that fail against Windows 2019 are:

error: __main__.SamTests.test_userAccountControl_computer_add_normal [
_ldb.LdbError: (53, 'LDAP error 53 LDAP_UNWILLING_TO_PERFORM -  <0000052D: SvcErr: DSID-031A1236, problem 5003 (WILL_NOT_PERFORM), data 0\n> <>')
error: __main__.SamTests.test_userAccountControl_computer_modify [
_ldb.LdbError: (53, 'LDAP error 53 LDAP_UNWILLING_TO_PERFORM -  <0000052D: SvcErr: DSID-031A1236, problem 5003 (WILL_NOT_PERFORM), data 0\n> <>')
error: __main__.SamTests.test_userAccountControl_user_add_0_uac [
_ldb.LdbError: (53, 'LDAP error 53 LDAP_UNWILLING_TO_PERFORM -  <0000052D: SvcErr: DSID-031A1236, problem 5003 (WILL_NOT_PERFORM), data 0\n> <>')
error: __main__.SamTests.test_userAccountControl_user_add_normal [
_ldb.LdbError: (53, 'LDAP error 53 LDAP_UNWILLING_TO_PERFORM -  <0000052D: SvcErr: DSID-031A1236, problem 5003 (WILL_NOT_PERFORM), data 0\n> <>')
error: __main__.SamTests.test_userAccountControl_user_modify [
_ldb.LdbError: (53, 'LDAP error 53 LDAP_UNWILLING_TO_PERFORM -  <0000052D: SvcErr: DSID-031A1236, problem 5003 (WILL_NOT_PERFORM), data 0\n> <>')

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 samdb: Fill in isCriticalSystemObject on any account type change
Andrew Bartlett [Thu, 21 Oct 2021 00:02:42 +0000 (13:02 +1300)] 
CVE-2020-25722 samdb: Fill in isCriticalSystemObject on any account type change

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 selftest: Adapt sam.py test_isCriticalSystemObject to new UF_WORKSTATI...
Andrew Bartlett [Wed, 20 Oct 2021 22:57:22 +0000 (11:57 +1300)] 
CVE-2020-25722 selftest: Adapt sam.py test_isCriticalSystemObject to new UF_WORKSTATION_TRUST_ACCOUNT default

Objects with objectclass computer now have UF_WORKSTATION_TRUST_ACCOUNT
by default and so this test must adapt.

The changes to this test passes against Windows 2019 except for
the new behaviour around the UF_WORKSTATION_TRUST_ACCOUNT default.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 dsdb: Add restrictions on computer accounts without a trailing $
Andrew Bartlett [Tue, 21 Sep 2021 23:29:02 +0000 (11:29 +1200)] 
CVE-2020-25722 dsdb: Add restrictions on computer accounts without a trailing $

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 dsdb: samldb_objectclass_trigger() is only called on ADD, so remove...
Andrew Bartlett [Tue, 21 Sep 2021 23:28:05 +0000 (11:28 +1200)] 
CVE-2020-25722 dsdb: samldb_objectclass_trigger() is only called on ADD, so remove indentation

This makes the code less indented and simpler to understand.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 selftest: Adapt selftest to restriction on swapping account types
Andrew Bartlett [Fri, 22 Oct 2021 03:18:51 +0000 (16:18 +1300)] 
CVE-2020-25722 selftest: Adapt selftest to restriction on swapping account types

This makes many of our tests pass again.  We do not pass against Windows 2019 on all
as this does not have this restriction at this time.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 selftest/priv_attrs: Mention that these knownfails are OK (for now)
Andrew Bartlett [Thu, 28 Oct 2021 01:47:30 +0000 (14:47 +1300)] 
CVE-2020-25722 selftest/priv_attrs: Mention that these knownfails are OK (for now)

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14775

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 dsdb: Prohibit mismatch between UF_ account types and objectclass.
Andrew Bartlett [Fri, 22 Oct 2021 03:07:46 +0000 (16:07 +1300)] 
CVE-2020-25722 dsdb: Prohibit mismatch between UF_ account types and objectclass.

There are a lot of knownfail entries added with this commit.  These
all need to be addressed and removed in subsequent commits which
will restructure the tests to pass within this new reality.

The restriction is not applied to users with administrator rights,
as this breaks a lot of tests and provides no security benefit.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 dsdb: Add tests for modifying objectClass, userAccountControl and...
Joseph Sutton [Fri, 29 Oct 2021 10:33:32 +0000 (23:33 +1300)] 
CVE-2020-25722 dsdb: Add tests for modifying objectClass, userAccountControl and sAMAccountName

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14889

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
3 years agoCVE-2020-25722 dsdb: Improve privileged and unprivileged tests for objectclass/doller/UAC
Andrew Bartlett [Fri, 22 Oct 2021 02:42:08 +0000 (15:42 +1300)] 
CVE-2020-25722 dsdb: Improve privileged and unprivileged tests for objectclass/doller/UAC

This helps ensure we cover off all the cases that matter
for objectclass/trailing-doller/userAccountControl

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 dsdb: objectclass computer becomes UF_WORKSTATION_TRUST by default
Andrew Bartlett [Wed, 15 Sep 2021 20:46:42 +0000 (08:46 +1200)] 
CVE-2020-25722 dsdb: objectclass computer becomes UF_WORKSTATION_TRUST by default

There are a lot of knownfail entries added with this commit.  These
all need to be addressed and removed in subsequent commits which
will restructure the tests to pass within this new reality.

This default applies even to users with administrator rights,
as changing the default based on permissions would break
to many assumptions.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 selftest: Catch errors from samdb.modify() in user_account_control...
Andrew Bartlett [Fri, 17 Sep 2021 01:41:40 +0000 (13:41 +1200)] 
CVE-2020-25722 selftest: Catch errors from samdb.modify() in user_account_control tests

This will allow these to be listed in a knownfail shortly.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 selftest: Catch possible errors in PasswordSettingsTestCase.test_pso_n...
Andrew Bartlett [Mon, 20 Sep 2021 02:54:03 +0000 (14:54 +1200)] 
CVE-2020-25722 selftest: Catch possible errors in PasswordSettingsTestCase.test_pso_none_applied()

This allows future patches to restrict changing the account type
without triggering an error.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 selftest: allow for future failures in BindTests.test_virtual_email_ac...
Andrew Bartlett [Mon, 20 Sep 2021 00:35:51 +0000 (12:35 +1200)] 
CVE-2020-25722 selftest: allow for future failures in BindTests.test_virtual_email_account_style_bind

This allows for any failures here to be handled via the knownfail system.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 selftest: Test combinations of account type and objectclass for creati...
Andrew Bartlett [Sun, 12 Sep 2021 22:21:03 +0000 (10:21 +1200)] 
CVE-2020-25722 selftest: Test combinations of account type and objectclass for creating a user

The idea here is to split out the restrictions seen on Windows 2019
at the schema level, as seen when acting as an administrator.

These pass against Windows 2019 except for the account type swapping
which is not wanted.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 selftest: Extend priv_attrs test - work around UF_NORMAL_ACCOUNT rules...
Andrew Bartlett [Mon, 13 Sep 2021 08:34:54 +0000 (20:34 +1200)] 
CVE-2020-25722 selftest: Extend priv_attrs test - work around UF_NORMAL_ACCOUNT rules on Windows 2019 (requires |UF_PASSWD_NOTREQD or a password) - extend to also cover the sensitive UF_TRUSTED_FOR_DELEGATION

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14703
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14778
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14775

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 dsdb: Restrict the setting of privileged attributes during LDAP add...
Andrew Bartlett [Fri, 13 Aug 2021 05:42:23 +0000 (17:42 +1200)] 
CVE-2020-25722 dsdb: Restrict the setting of privileged attributes during LDAP add/modify

The remaining failures in the priv_attrs (not the strict one) test are
due to missing objectclass constraints on the administrator which should
be addressed, but are not a security issue.

A better test for confirming constraints between objectclass and
userAccountControl UF_NORMAL_ACCONT/UF_WORKSTATION_TRUST values would
be user_account_control.py.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14703
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14778
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14775

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 dsdb: Move krbtgt password setup after the point of checking if any...
Andrew Bartlett [Wed, 11 Aug 2021 23:10:09 +0000 (11:10 +1200)] 
CVE-2020-25722 dsdb: Move krbtgt password setup after the point of checking if any passwords are changed

This allows the add of an RODC, before setting the password, to avoid
this module, which helps isolate testing of security around the
msDS-SecondaryKrbTgtNumber attribute.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14703

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-25722 dsdb: Tests for our known set of privileged attributes
Andrew Bartlett [Tue, 10 Aug 2021 10:31:02 +0000 (22:31 +1200)] 
CVE-2020-25722 dsdb: Tests for our known set of privileged attributes

This, except for where we choose to disagree, does pass
against Windows 2019.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14703
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14778
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14775

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
3 years agoCVE-2020-17049 tests/krb5: Check account name and SID in PAC for S4U tests
Joseph Sutton [Thu, 21 Oct 2021 03:46:56 +0000 (16:46 +1300)] 
CVE-2020-17049 tests/krb5: Check account name and SID in PAC for S4U tests

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14642

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Mon Oct 25 09:23:35 UTC 2021 on sn-devel-184

(cherry picked from commit c174e9ebe715aad6910d53c1f427a0512c09d651)

3 years agoCVE-2020-25722 selftest: Use self.assertRaisesLdbError() in user_account_control...
Andrew Bartlett [Thu, 16 Sep 2021 04:09:24 +0000 (16:09 +1200)] 
CVE-2020-25722 selftest: Use self.assertRaisesLdbError() in user_account_control.py test

This changes most of the simple pattern with self.samdb.modify()
to use the wrapper.  Some other calls still need to be converted, while
the complex decision tree tests should remain as-is for now.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Oct  4 21:55:43 UTC 2021 on sn-devel-184

(cherry picked from commit b45190bdac7bd9dcefd5ed88be4bd9a97a712664)

3 years agoCVE-2020-25722 selftest: Update user_account_control tests to pass against Windows...
Andrew Bartlett [Mon, 30 Aug 2021 06:17:47 +0000 (18:17 +1200)] 
CVE-2020-25722 selftest: Update user_account_control tests to pass against Windows 2019

This gets us closer to passing against Windows 2019, without
making major changes to what was tested.  More tests are needed,
but it is important to get what was being tested tested again.

Account types (eg UF_NORMAL_ACCOUNT, UF_WORKSTATION_TRUST_ACCOUNT)
are now required on all objects, this can't be omitted any more.

Also for UF_NORMAL_ACCOUNT for these accounts without a password
set |UF_PASSWD_NOTREQD must be included.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Sep 15 08:49:11 UTC 2021 on sn-devel-184

(cherry picked from commit d12cb47724c2e8d19a28286d4c3ef72271a002fd)

3 years agoCVE-2020-25722 selftest: Replace internal loop in test_uac_bits_set() using @DynamicT...
Andrew Bartlett [Mon, 30 Aug 2021 02:54:39 +0000 (14:54 +1200)] 
CVE-2020-25722 selftest: Replace internal loop in test_uac_bits_set() using @DynamicTestClass

This generates a single test per bit which is easier to
debug.  Elsewhere we use this pattern where we want to
be able to put some cases in a knownfail, which is otherwise
not possible.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753
(cherry picked from commit 17ae0319db53a7b88e7fb44a9e2fd4bf1d1daa0e)

3 years agoCVE-2020-25722 selftest: Replace internal loop in test_uac_bits_add() using @DynamicT...
Andrew Bartlett [Mon, 30 Aug 2021 02:51:27 +0000 (14:51 +1200)] 
CVE-2020-25722 selftest: Replace internal loop in test_uac_bits_add() using @DynamicTestClass

This generates a single test per bit which is easier to
debug.  Elsewhere we use this pattern where we want to
be able to put some cases in a knownfail, which is otherwise
not possible.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753
(cherry picked from commit 60f1b6cf0ef0bf6736d8db9c53fa48fe9f3d8e75)

3 years agoCVE-2020-25722 selftest: Use @DynamicTestCase in user_account_control test_uac_bits_u...
Andrew Bartlett [Mon, 30 Aug 2021 02:37:06 +0000 (14:37 +1200)] 
CVE-2020-25722 selftest: Use @DynamicTestCase in user_account_control test_uac_bits_unrelated_modify()

This is a nice easy example of how the test generation
code works, and it combined nicely with the earlier
patch to return string names from the UF_ constants.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14753
(cherry picked from commit 8701ce492fc3a209035b152961d8c17e801b082a)