samba.git
2 years agoCVE-2021-23192: dcesrv_core: add better debugging to dcesrv_fault_disconnect()
Stefan Metzmacher [Fri, 13 Nov 2020 10:25:41 +0000 (11:25 +0100)]
CVE-2021-23192: dcesrv_core: add better debugging to dcesrv_fault_disconnect()

It's better to see the location that triggered the fault.

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Samuel Cabrero <scabrero@samba.org>
2 years agoCVE-2020-25722 selftest: Ensure check for duplicate servicePrincipalNames is not...
Joseph Sutton [Tue, 2 Nov 2021 08:00:00 +0000 (21:00 +1300)]
CVE-2020-25722 selftest: Ensure check for duplicate servicePrincipalNames is not bypassed for an add operation

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

If one of the objectClass checks passed, samldb_add() could return
through one of the samldb_fill_*() functions and skip the
servicePrincipalName uniqueness checking.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agoCVE-2020-25722 selftest: Add test for duplicate servicePrincipalNames on an add operation
Joseph Sutton [Tue, 2 Nov 2021 08:21:17 +0000 (21:21 +1300)]
CVE-2020-25722 selftest: Add test for duplicate servicePrincipalNames on an add operation

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agoCVE-2020-25722 pytests: Give computer accounts unique (and valid) sAMAccountNames...
Stefan Metzmacher [Tue, 2 Nov 2021 13:11:27 +0000 (14:11 +0100)]
CVE-2020-25722 pytests: Give computer accounts unique (and valid) sAMAccountNames and SPNs

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2 years agoCVE-2020-25719 selftest: Always expect a PAC in TGS replies with Heimdal
Andrew Bartlett [Tue, 2 Nov 2021 01:02:14 +0000 (14:02 +1300)]
CVE-2020-25719 selftest: Always expect a PAC in TGS replies with Heimdal

This is tested in other places already, but this ensures a global
check that a TGS-REP has a PAC, regardless.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14561
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agoRevert "CVE-2020-25719 heimdal:kdc: Require authdata to be present"
Andrew Bartlett [Tue, 2 Nov 2021 01:52:22 +0000 (14:52 +1300)]
Revert "CVE-2020-25719 heimdal:kdc: Require authdata to be present"

This reverts an earlier commit that was incorrect.

It is not Samba practice to include a revert, but at this point in
the patch preperation the ripple though the knownfail files is
more trouble than can be justified.

It is not correct to refuse to parse all tickets with no authorization
data, only for the KDC to require that a PAC is found, which is done
in "heimdal:kdc: Require PAC to be present"

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agoCVE-2020-25718 heimdal:kdc: Add comment about tests for tickets of users not revealed...
Joseph Sutton [Fri, 29 Oct 2021 02:53:33 +0000 (15:53 +1300)]
CVE-2020-25718 heimdal:kdc: Add comment about tests for tickets of users not revealed to an RODC

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 tests/krb5: Add tests for using a ticket with a renamed account
Joseph Sutton [Fri, 29 Oct 2021 02:07:07 +0000 (15:07 +1300)]
CVE-2020-25719 tests/krb5: Add tests for using a ticket with a renamed account

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>
2 years agoCVE-2020-25718 tests/krb5: Only fetch RODC account credentials when necessary
Joseph Sutton [Fri, 29 Oct 2021 02:43:28 +0000 (15:43 +1300)]
CVE-2020-25718 tests/krb5: Only fetch RODC account credentials when necessary

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>
2 years agoCVE-2020-25719 heimdal:kdc: Require PAC to be present
Joseph Sutton [Fri, 29 Oct 2021 01:35:52 +0000 (14:35 +1300)]
CVE-2020-25719 heimdal:kdc: Require PAC to be present

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>
2 years agoCVE-2020-25722 kdc: Do not honour a request for a 3-part SPN (ending in our domain...
Andrew Bartlett [Mon, 4 Oct 2021 02:18:34 +0000 (15:18 +1300)]
CVE-2020-25722 kdc: Do not honour a request for a 3-part SPN (ending in our domain/realm) unless a DC

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agoCVE-2020-25719 heimdal:kdc: Verify PAC in TGT provided for user-to-user authentication
Joseph Sutton [Wed, 27 Oct 2021 02:52:06 +0000 (15:52 +1300)]
CVE-2020-25719 heimdal:kdc: Verify PAC in TGT provided for user-to-user authentication

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 heimdal:kdc: Check name in request against name in user-to-user TGT
Joseph Sutton [Wed, 27 Oct 2021 02:51:58 +0000 (15:51 +1300)]
CVE-2020-25719 heimdal:kdc: Check name in request against name in user-to-user TGT

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 heimdal:kdc: Use sname from request rather than user-to-user TGT clien...
Joseph Sutton [Wed, 27 Oct 2021 00:50:03 +0000 (13:50 +1300)]
CVE-2020-25719 heimdal:kdc: Use sname from request rather than user-to-user TGT client name

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 heimdal:kdc: Move fetching krbtgt entry to before enctype selection
Joseph Sutton [Tue, 26 Oct 2021 07:34:44 +0000 (20:34 +1300)]
CVE-2020-25719 heimdal:kdc: Move fetching krbtgt entry to before enctype selection

This allows us to use it when validating user-to-user.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 heimdal:kdc: Check return code
Joseph Sutton [Wed, 27 Oct 2021 00:53:25 +0000 (13:53 +1300)]
CVE-2020-25719 heimdal:kdc: Check return code

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 s4:kdc: Add KDC support for PAC_REQUESTER_SID PAC buffer
Joseph Sutton [Tue, 26 Oct 2021 07:42:41 +0000 (20:42 +1300)]
CVE-2020-25719 s4:kdc: Add KDC support for PAC_REQUESTER_SID PAC buffer

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>
2 years agoCVE-2020-25722 Ensure the structural objectclass cannot be changed
Andrew Bartlett [Tue, 19 Oct 2021 22:36:58 +0000 (11:36 +1300)]
CVE-2020-25722 Ensure the structural objectclass cannot be changed

If the structural objectclass is allowed to change, then the restrictions
locking an object to remaining a user or computer will not be enforcable.

Likewise other LDAP inheritance rules, which allow only certain
child objects can be bypassed, which can in turn allow creation of
(unprivileged) users where only DNS objects were expected.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agoCVE-2020-25721 auth: Fill in the new HAS_SAM_NAME_AND_SID values
Andrew Bartlett [Sun, 26 Sep 2021 23:10:02 +0000 (12:10 +1300)]
CVE-2020-25721 auth: Fill in the new HAS_SAM_NAME_AND_SID values

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>
2 years agoCVE-2020-25719 kdc: Avoid races and multiple DB lookups in s4u2self check
Andrew Bartlett [Thu, 7 Oct 2021 19:29:51 +0000 (08:29 +1300)]
CVE-2020-25719 kdc: Avoid races and multiple DB lookups in s4u2self check

Looking up the DB twice is subject to a race and is a poor
use of resources, so instead just pass in the record we
already got when trying to confirm that the server in
S4U2Self is the same as the requesting client.

The client record has already been bound to the the
original client by the SID check in the PAC.

Likewise by looking up server only once we ensure
that the keys looked up originally are in the record
we confirm the SID for here.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agoCVE-2020-25718 kdc: Return ERR_POLICY if RODC krbtgt account is invalid
Joseph Sutton [Sun, 3 Oct 2021 23:43:13 +0000 (12:43 +1300)]
CVE-2020-25718 kdc: Return ERR_POLICY if RODC krbtgt account is invalid

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>
2 years agoCVE-2020-25718 kdc: Confirm the RODC was allowed to issue a particular ticket
Andrew Bartlett [Fri, 1 Oct 2021 03:14:37 +0000 (16:14 +1300)]
CVE-2020-25718 kdc: Confirm the RODC was allowed to issue a particular ticket

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agoCVE-2020-25718 dsdb: Bring sid_helper.c into common code as rodc_helper.c
Andrew Bartlett [Fri, 1 Oct 2021 02:59:28 +0000 (15:59 +1300)]
CVE-2020-25718 dsdb: Bring sid_helper.c into common code as rodc_helper.c

These common routines will assist the KDC to do the same access
checking as the RPC servers need to do regarding which accounts
a RODC can act with regard to.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agoCVE-2020-25718 s4-rpc_server: Add in debug messages into RODC processing
Andrew Bartlett [Fri, 1 Oct 2021 02:57:41 +0000 (15:57 +1300)]
CVE-2020-25718 s4-rpc_server: Add in debug messages into RODC processing

These are added for the uncommon cases.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agoCVE-2020-25718 s4-rpc_server: Explain why we use DSDB_SEARCH_SHOW_EXTENDED_DN in...
Andrew Bartlett [Fri, 1 Oct 2021 01:31:00 +0000 (14:31 +1300)]
CVE-2020-25718 s4-rpc_server: Explain why we use DSDB_SEARCH_SHOW_EXTENDED_DN in RODC access check

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agoCVE-2020-25718 s4-rpc_server: Remove unused attributes in RODC check
Andrew Bartlett [Thu, 30 Sep 2021 23:29:49 +0000 (12:29 +1300)]
CVE-2020-25718 s4-rpc_server: Remove unused attributes in RODC check

In particular the objectGUID is no longer used, and in the NETLOGON case
the special case for msDS-KrbTgtLink does not apply.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agoCVE-2020-25718 s4-rpc_server: Provide wrapper samdb_confirm_rodc_allowed_to_repl_to()
Andrew Bartlett [Thu, 30 Sep 2021 23:25:30 +0000 (12:25 +1300)]
CVE-2020-25718 s4-rpc_server: Provide wrapper samdb_confirm_rodc_allowed_to_repl_to()

This shares the lookup of the tokenGroups attribute.

There will be a new caller that does not want to do this step,
so this is a wrapper of samdb_confirm_rodc_allowed_to_repl_to_sid_list()
rather than part of it

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agoCVE-2020-25718 s4-rpc_server: Confirm that the RODC has the UF_PARTIAL_SECRETS_ACCOUN...
Andrew Bartlett [Thu, 30 Sep 2021 23:01:12 +0000 (12:01 +1300)]
CVE-2020-25718 s4-rpc_server: Confirm that the RODC has the UF_PARTIAL_SECRETS_ACCOUNT bit

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agoCVE-2020-25718 s4-rpc_server: Put msDS-KrbTgtLinkBL and UF_INTERDOMAIN_TRUST_ACCOUNT...
Andrew Bartlett [Thu, 30 Sep 2021 22:55:11 +0000 (11:55 +1300)]
CVE-2020-25718 s4-rpc_server: Put msDS-KrbTgtLinkBL and UF_INTERDOMAIN_TRUST_ACCOUNT RODC checks in common

While these checks were not in the NETLOGON case, there is no sense where
an RODC should be resetting a bad password count on either a
UF_INTERDOMAIN_TRUST_ACCOUNT nor a RODC krbtgt account.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agoCVE-2020-25718 s4-rpc_server: Put RODC reveal/never reveal logic into a single helper...
Andrew Bartlett [Thu, 30 Sep 2021 22:38:16 +0000 (11:38 +1300)]
CVE-2020-25718 s4-rpc_server: Put RODC reveal/never reveal logic into a single helper function

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agoCVE-2020-25718 s4-rpc_server: Obtain the user tokenGroups earlier
Andrew Bartlett [Thu, 30 Sep 2021 22:09:48 +0000 (11:09 +1300)]
CVE-2020-25718 s4-rpc_server: Obtain the user tokenGroups earlier

This will allow the creation of a common helper routine that
takes the token SID list (from tokenGroups or struct auth_user_info_dc)
and returns the allowed/denied result.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agoCVE-2020-25718 s4-rpc_server: Change sid list functions to operate on a array of...
Andrew Bartlett [Thu, 30 Sep 2021 21:47:29 +0000 (10:47 +1300)]
CVE-2020-25718 s4-rpc_server: Change sid list functions to operate on a array of struct dom_sid

This is instead of an array of struct dom_sid *.

The reason is that auth_user_info_dc has an array of struct dom_sid
(the user token) and for checking if an RODC should be allowed
to print a particular ticket, we want to reuse that a rather
then reconstruct it via tokenGroups.

This also avoids a lot of memory allocation.

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agoCVE-2020-25718 kdc: Remove unused samba_kdc_get_pac_blob()
Andrew Bartlett [Thu, 30 Sep 2021 01:55:06 +0000 (14:55 +1300)]
CVE-2020-25718 kdc: Remove unused samba_kdc_get_pac_blob()

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

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2 years agoCVE-2020-25719 heimdal:kdc: Require authdata to be present
Joseph Sutton [Mon, 18 Oct 2021 02:07:58 +0000 (15:07 +1300)]
CVE-2020-25719 heimdal:kdc: Require authdata to be present

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>
2 years agoCVE-2020-25719 s4:kdc: Add KDC support for PAC_ATTRIBUTES_INFO PAC buffer
Joseph Sutton [Tue, 26 Oct 2021 07:41:31 +0000 (20:41 +1300)]
CVE-2020-25719 s4:kdc: Add KDC support for PAC_ATTRIBUTES_INFO PAC buffer

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>
2 years agoCVE-2020-25719 s4:kdc: Check if the pac is valid before updating it
Andreas Schneider [Mon, 9 Aug 2021 15:20:31 +0000 (17:20 +0200)]
CVE-2020-25719 s4:kdc: Check if the pac is valid before updating it

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 s4:kdc: Add samba_kdc_validate_pac_blob()
Andreas Schneider [Mon, 9 Aug 2021 15:19:45 +0000 (17:19 +0200)]
CVE-2020-25719 s4:kdc: Add samba_kdc_validate_pac_blob()

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 s4:kdc: Remove trailing spaces in pac-glue.c
Andreas Schneider [Fri, 6 Aug 2021 10:03:49 +0000 (12:03 +0200)]
CVE-2020-25719 s4:kdc: Remove trailing spaces in pac-glue.c

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 mit_samba: Create the talloc context earlier
Andreas Schneider [Mon, 9 Aug 2021 15:25:53 +0000 (17:25 +0200)]
CVE-2020-25719 mit_samba: Create the talloc context earlier

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 mit_samba: The samba_princ_needs_pac check should be on the server...
Andreas Schneider [Mon, 9 Aug 2021 15:22:52 +0000 (17:22 +0200)]
CVE-2020-25719 mit_samba: The samba_princ_needs_pac check should be on the server entry

This does the same check as the hdb plugin now. The client check is already
done earlier.

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 mit-samba: Rework PAC handling in kdb_samba_db_sign_auth_data()
Andreas Schneider [Mon, 12 Jul 2021 12:00:19 +0000 (14:00 +0200)]
CVE-2020-25719 mit-samba: Rework PAC handling in kdb_samba_db_sign_auth_data()

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 mit-samba: Handle no DB entry in mit_samba_get_pac()
Andreas Schneider [Mon, 12 Jul 2021 11:58:57 +0000 (13:58 +0200)]
CVE-2020-25719 mit-samba: Handle no DB entry in mit_samba_get_pac()

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 mit-samba: Add mit_samba_princ_needs_pac()
Andreas Schneider [Mon, 12 Jul 2021 11:12:00 +0000 (13:12 +0200)]
CVE-2020-25719 mit-samba: Add mit_samba_princ_needs_pac()

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 mit-samba: If we use client_princ, always lookup the db entry
Andreas Schneider [Mon, 12 Jul 2021 09:20:29 +0000 (11:20 +0200)]
CVE-2020-25719 mit-samba: If we use client_princ, always lookup the db entry

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 mit-samba: Add ks_free_principal()
Andreas Schneider [Wed, 14 Jul 2021 12:51:34 +0000 (14:51 +0200)]
CVE-2020-25719 mit-samba: Add ks_free_principal()

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

[abartlet@samba.org As submitted in patch to Samba bugzilla
 to address this issue as https://attachments.samba.org/attachment.cgi?id=16724
 on overall bug https://bugzilla.samba.org/show_bug.cgi?id=14725]

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2 years agoCVE-2020-25719 mit-samba: Make ks_get_principal() internally public
Andreas Schneider [Mon, 12 Jul 2021 10:32:12 +0000 (12:32 +0200)]
CVE-2020-25719 mit-samba: Make ks_get_principal() internally public

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25722 pytest: Raise an error when adding a dynamic test that would overwrite...
Joseph Sutton [Wed, 27 Oct 2021 06:18:20 +0000 (19:18 +1300)]
CVE-2020-25722 pytest: Raise an error when adding a dynamic test that would overwrite an existing test

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 s4/torture: Expect additional PAC buffers
Joseph Sutton [Thu, 28 Oct 2021 22:00:38 +0000 (11:00 +1300)]
CVE-2020-25719 s4/torture: Expect additional PAC buffers

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>
2 years agoCVE-2020-25719 tests/krb5: Add tests for mismatched names with user-to-user
Joseph Sutton [Tue, 26 Oct 2021 08:09:32 +0000 (21:09 +1300)]
CVE-2020-25719 tests/krb5: Add tests for mismatched names with user-to-user

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 tests/krb5: Add test for user-to-user with no sname
Joseph Sutton [Tue, 26 Oct 2021 08:06:58 +0000 (21:06 +1300)]
CVE-2020-25719 tests/krb5: Add test for user-to-user with no sname

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 tests/krb5: Add tests for requester SID PAC buffer
Joseph Sutton [Tue, 26 Oct 2021 08:04:25 +0000 (21:04 +1300)]
CVE-2020-25719 tests/krb5: Add tests for requester SID PAC buffer

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>
2 years agoCVE-2020-25719 tests/krb5: Add tests for PAC-REQUEST padata
Joseph Sutton [Tue, 26 Oct 2021 08:19:44 +0000 (21:19 +1300)]
CVE-2020-25719 tests/krb5: Add tests for PAC-REQUEST padata

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>
2 years agoCVE-2020-25719 tests/krb5: Add tests for PAC attributes buffer
Joseph Sutton [Tue, 26 Oct 2021 08:02:08 +0000 (21:02 +1300)]
CVE-2020-25719 tests/krb5: Add tests for PAC attributes buffer

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>
2 years agoCVE-2020-25719 tests/krb5: Add expected parameters to cache key for obtaining tickets
Joseph Sutton [Tue, 26 Oct 2021 22:18:36 +0000 (11:18 +1300)]
CVE-2020-25719 tests/krb5: Add expected parameters to cache key for obtaining tickets

If multiple calls to get_tgt() or get_service_ticket() specify different
expected parameters, we want to perform the request again so that the
checking can be performed, rather than reusing a previously obtained
ticket and potentially skipping checks.

It should be fine to cache tickets with the same expected parameters, as
tickets that fail to be obtained will not be stored in the cache, so the
checking will happen for every call.

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>
2 years agoCVE-2020-25719 tests/krb5: Add EXPECT_PAC environment variable to expect pac from...
Joseph Sutton [Tue, 26 Oct 2021 07:47:24 +0000 (20:47 +1300)]
CVE-2020-25719 tests/krb5: Add EXPECT_PAC environment variable to expect pac from all TGS tickets

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>
2 years agoCVE-2020-25719 tests/krb5: Add testing for PAC_TYPE_REQUESTER_SID PAC buffer
Joseph Sutton [Tue, 26 Oct 2021 07:51:13 +0000 (20:51 +1300)]
CVE-2020-25719 tests/krb5: Add testing for PAC_TYPE_REQUESTER_SID PAC buffer

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>
2 years agoCVE-2020-25719 tests/krb5: Add testing for PAC_TYPE_ATTRIBUTES_INFO PAC buffer
Joseph Sutton [Tue, 26 Oct 2021 07:50:09 +0000 (20:50 +1300)]
CVE-2020-25719 tests/krb5: Add testing for PAC_TYPE_ATTRIBUTES_INFO PAC buffer

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>
2 years agoCVE-2020-25719 tests/krb5: Add _modify_tgt() method for modifying already obtained...
Joseph Sutton [Tue, 26 Oct 2021 21:25:08 +0000 (10:25 +1300)]
CVE-2020-25719 tests/krb5: Add _modify_tgt() method for modifying already obtained tickets

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>
2 years agoCVE-2020-25719 tests/krb5: Extend _get_tgt() method to allow more modifications to...
Joseph Sutton [Tue, 26 Oct 2021 08:12:12 +0000 (21:12 +1300)]
CVE-2020-25719 tests/krb5: Extend _get_tgt() method to allow more modifications to tickets

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>
2 years agoCVE-2020-25719 tests/krb5: tests/krb5: Adjust expected error code for S4U2Self no...
Joseph Sutton [Tue, 26 Oct 2021 08:08:34 +0000 (21:08 +1300)]
CVE-2020-25719 tests/krb5: tests/krb5: Adjust expected error code for S4U2Self no-PAC tests

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>
2 years agoCVE-2020-25719 tests/krb5: Adjust expected error codes for user-to-user tests
Joseph Sutton [Tue, 26 Oct 2021 08:20:51 +0000 (21:20 +1300)]
CVE-2020-25719 tests/krb5: Adjust expected error codes for user-to-user tests

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 tests/krb5: Adjust PAC tests to prepare for new PAC_ATTRIBUTES_INFO...
Joseph Sutton [Tue, 26 Oct 2021 08:15:53 +0000 (21:15 +1300)]
CVE-2020-25719 tests/krb5: Adjust PAC tests to prepare for new PAC_ATTRIBUTES_INFO buffer

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>
2 years agoCVE-2020-25719 tests/krb5: Use correct credentials for user-to-user tests
Joseph Sutton [Tue, 26 Oct 2021 08:14:45 +0000 (21:14 +1300)]
CVE-2020-25719 tests/krb5: Use correct credentials for user-to-user tests

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 tests/krb5: Return ticket from _tgs_req()
Joseph Sutton [Tue, 26 Oct 2021 08:05:08 +0000 (21:05 +1300)]
CVE-2020-25719 tests/krb5: Return ticket from _tgs_req()

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>
2 years agoCVE-2020-25719 tests/krb5: Expect 'renew-till' element when renewing a TGT
Joseph Sutton [Tue, 26 Oct 2021 07:51:46 +0000 (20:51 +1300)]
CVE-2020-25719 tests/krb5: Expect 'renew-till' element when renewing a TGT

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>
2 years agoCVE-2020-25719 tests/krb5: Don't expect a kvno for user-to-user
Joseph Sutton [Tue, 26 Oct 2021 07:51:34 +0000 (20:51 +1300)]
CVE-2020-25719 tests/krb5: Don't expect a kvno for user-to-user

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25719 tests/krb5: Allow update_pac_checksums=True if the PAC is not present
Joseph Sutton [Tue, 26 Oct 2021 07:47:53 +0000 (20:47 +1300)]
CVE-2020-25719 tests/krb5: Allow update_pac_checksums=True if the PAC is not present

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>
2 years agoCVE-2020-25719 tests/krb5: Provide expected parameters for both AS-REQs in get_tgt()
Joseph Sutton [Tue, 26 Oct 2021 07:44:45 +0000 (20:44 +1300)]
CVE-2020-25719 tests/krb5: Provide expected parameters for both AS-REQs in get_tgt()

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>
2 years agoCVE-2020-25719 krb5pac.idl: Add PAC_REQUESTER_SID PAC buffer type
Joseph Sutton [Tue, 26 Oct 2021 07:33:49 +0000 (20:33 +1300)]
CVE-2020-25719 krb5pac.idl: Add PAC_REQUESTER_SID PAC buffer type

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>
2 years agoCVE-2020-25719 krb5pac.idl: Add PAC_ATTRIBUTES_INFO PAC buffer type
Joseph Sutton [Tue, 26 Oct 2021 07:33:38 +0000 (20:33 +1300)]
CVE-2020-25719 krb5pac.idl: Add PAC_ATTRIBUTES_INFO PAC buffer type

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>
2 years agoCVE-2020-25718 tests/krb5: Fix indentation
Joseph Sutton [Tue, 26 Oct 2021 07:56:10 +0000 (20:56 +1300)]
CVE-2020-25718 tests/krb5: Fix indentation

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>
2 years agoCVE-2020-25722 selftest: Adapt ldap.py tests to new objectClass restrictions
Joseph Sutton [Thu, 28 Oct 2021 23:20:49 +0000 (12:20 +1300)]
CVE-2020-25722 selftest: Adapt ldap.py tests to new objectClass restrictions

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25722 s4/dsdb/util: remove unused dsdb_get_single_valued_attr()
Douglas Bagnall [Thu, 21 Oct 2021 00:49:28 +0000 (13:49 +1300)]
CVE-2020-25722 s4/dsdb/util: remove unused dsdb_get_single_valued_attr()

Nobody uses it now. It never really did what it said it did. Almost
every use was wrong. It was a trap.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25722 s4/dsdb/pwd_hash: rework pwdLastSet bypass
Douglas Bagnall [Wed, 20 Oct 2021 04:20:54 +0000 (17:20 +1300)]
CVE-2020-25722 s4/dsdb/pwd_hash: rework pwdLastSet bypass

This tightens the logic a bit, in that a message with trailing DELETE
elements is no longer accepted when the bypass flag is set. In any case
this is an unlikely scenario as this is an internal flag set by a private
control in pdb_samba_dsdb_replace_by_sam().

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25722 s4/dsdb/pwd_hash: password_hash_bypass gets all values
Douglas Bagnall [Wed, 20 Oct 2021 04:19:42 +0000 (17:19 +1300)]
CVE-2020-25722 s4/dsdb/pwd_hash: password_hash_bypass gets all values

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25722 s4/dsdb/samldb: samldb_fsmo_role_owner_check() wants one value
Douglas Bagnall [Wed, 20 Oct 2021 23:52:07 +0000 (12:52 +1300)]
CVE-2020-25722 s4/dsdb/samldb: samldb_fsmo_role_owner_check() wants one value

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25722 s4/dsdb/samldb: samldb_fsmo_role_owner_check checks values
Douglas Bagnall [Wed, 20 Oct 2021 04:18:21 +0000 (17:18 +1300)]
CVE-2020-25722 s4/dsdb/samldb: samldb_fsmo_role_owner_check checks values

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25722 s4/dsdb/samldb: samldb_service_principal_names_change checks values
Douglas Bagnall [Wed, 20 Oct 2021 04:18:10 +0000 (17:18 +1300)]
CVE-2020-25722 s4/dsdb/samldb: samldb_service_principal_names_change checks values

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25722 s4/dsdb/samldb: samldb_group_type_change() checks all values
Douglas Bagnall [Wed, 20 Oct 2021 04:17:50 +0000 (17:17 +1300)]
CVE-2020-25722 s4/dsdb/samldb: samldb_group_type_change() checks all values

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25722 s4/dsdb/samldb: samldb_lockout_time() checks all values
Douglas Bagnall [Wed, 20 Oct 2021 04:17:31 +0000 (17:17 +1300)]
CVE-2020-25722 s4/dsdb/samldb: samldb_lockout_time() checks all values

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25722 s4/dsdb/samldb: samldb_pwd_last_set_change() checks all values
Douglas Bagnall [Wed, 20 Oct 2021 04:16:34 +0000 (17:16 +1300)]
CVE-2020-25722 s4/dsdb/samldb: samldb_pwd_last_set_change() checks all values

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25722 s4/dsdb/samldb _user_account_control_change() always add final value
Douglas Bagnall [Wed, 20 Oct 2021 04:15:43 +0000 (17:15 +1300)]
CVE-2020-25722 s4/dsdb/samldb _user_account_control_change() always add final value

dsdb_get_single_valued_attr() was finding the last non-delete element for
userAccountControl and changing its value to the computed value.
Unfortunately, the last non-delete element might not be the last element,
and a subsequent delete might remove it.

Instead we just add a replace on the end.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25722 s4/dsdb/samldb: samldb_user_account_control_change() checks all values
Douglas Bagnall [Wed, 20 Oct 2021 04:15:00 +0000 (17:15 +1300)]
CVE-2020-25722 s4/dsdb/samldb: samldb_user_account_control_change() checks all values

There is another call to dsdb_get_expected_new_values() in this function
that we change in the next commit.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25722 s4/dsdb/samldb: samldb_prim_group_change() checks all values
Douglas Bagnall [Wed, 20 Oct 2021 04:14:05 +0000 (17:14 +1300)]
CVE-2020-25722 s4/dsdb/samldb: samldb_prim_group_change() checks all values

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25722 s4/dsdb/samldb: samldb_schema_add_handle_mapiid() checks all values
Douglas Bagnall [Wed, 20 Oct 2021 04:13:35 +0000 (17:13 +1300)]
CVE-2020-25722 s4/dsdb/samldb: samldb_schema_add_handle_mapiid() checks all values

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25722 s4/dsdb/samldb: samldb_schema_add_handle_linkid() checks all values
Douglas Bagnall [Wed, 20 Oct 2021 04:12:49 +0000 (17:12 +1300)]
CVE-2020-25722 s4/dsdb/samldb: samldb_schema_add_handle_linkid() checks all values

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25722 s4/dsdb/samldb: samldb_sam_accountname_valid_check() check all values
Douglas Bagnall [Fri, 22 Oct 2021 01:52:49 +0000 (14:52 +1300)]
CVE-2020-25722 s4/dsdb/samldb: samldb_sam_accountname_valid_check() check all values

Using dsdb_get_expected_new_values().

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25722 s4/dsdb/samldb: samldb_get_single_valued_attr() check all values
Douglas Bagnall [Wed, 20 Oct 2021 04:10:44 +0000 (17:10 +1300)]
CVE-2020-25722 s4/dsdb/samldb: samldb_get_single_valued_attr() check all values

using dsdb_get_expected_new_values().

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25722 s4/dsdb modules: add dsdb_get_expected_new_values()
Douglas Bagnall [Wed, 20 Oct 2021 04:09:21 +0000 (17:09 +1300)]
CVE-2020-25722 s4/dsdb modules: add dsdb_get_expected_new_values()

This function collects a superset of all the new values for the specified
attribute that could result from an ldb add or modify message.

In most cases -- where there is a single add or modify -- the exact set
of added values is returned, and this is done reasonably efficiently
using the existing element. Where it gets complicated is when there are
multiple elements for the same attribute in a message. Anything added
before a replace or delete will be included in these results but may not
end up in the database if the message runs its course. Examples:

   sequence           result
1. ADD                the element is returned (exact)
2. REPLACE            the element is returned (exact)
3. ADD, ADD           both elements are concatenated together (exact)
4. ADD, REPLACE       both elements are concatenated together (superset)
5. REPLACE, ADD       both elements are concatenated together (exact)
6. ADD, DEL, ADD      adds are concatenated together (superset)
7. REPLACE, REPLACE   both concatenated (superset)
8. DEL, ADD           last element is returned (exact)

Why this? In the past we have treated dsdb_get_single_valued_attr() as if
it returned the complete set of possible database changes, when in fact it
only returned the last non-delete. That is, it could have missed values
in examples 3-7 above.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2 years agoCVE-2020-25722 s4/dsdb/samldb: reject SPN with too few/many components
Douglas Bagnall [Fri, 22 Oct 2021 03:03:18 +0000 (16:03 +1300)]
CVE-2020-25722 s4/dsdb/samldb: reject SPN with too few/many components

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>
2 years agoCVE-2020-25722 s4/dsdb/samldb: check for SPN uniqueness, including aliases
Douglas Bagnall [Fri, 22 Oct 2021 00:14:32 +0000 (13:14 +1300)]
CVE-2020-25722 s4/dsdb/samldb: check for SPN uniqueness, including aliases

Not only should it not be possible to add a servicePrincipalName that
is already present in the domain, it should not be possible to add one
that is implied by an entry in sPNMappings, unless the user is adding
an alias to another SPN and has rights to alter that one.

For example, with the default sPNMappings, cifs/ is an alias pointing to
host/, meaning if there is no cifs/example.com SPN, the host/example.com
one will be used instead. A user can add the cifs/example.com SPN only
if they can also change the host/example.com one (because adding the
cifs/ effectively changes the host/). The reverse is refused in all cases,
unless they happen to be on the same object. That is, if there is a
cifs/example.com SPN, there is no way to add host/example.com elsewhere.

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>
2 years agoCVE-2020-25722 s4/dsdb/samldb: check sAMAccountName for illegal characters
Douglas Bagnall [Fri, 22 Oct 2021 02:27:25 +0000 (15:27 +1300)]
CVE-2020-25722 s4/dsdb/samldb: check sAMAccountName for illegal characters

This only for the real account name, not the account name implicit in
a UPN. It doesn't matter if a UPN implies an illegal sAMAccountName,
since that is not going to conflict with a real one.

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>
2 years agoCVE-2020-25722 s4/dsdb/samldb: check for clashes in UPNs/samaccountnames
Douglas Bagnall [Fri, 22 Oct 2021 00:17:34 +0000 (13:17 +1300)]
CVE-2020-25722 s4/dsdb/samldb: check for clashes in UPNs/samaccountnames

We already know duplicate sAMAccountNames and UserPrincipalNames are bad,
but we also have to check against the values these imply in each other.

For example, imagine users with SAM account names "Alice" and "Bob" in
the realm "example.com". If they do not have explicit UPNs, by the logic
of MS-ADTS 5.1.1.1.1 they use the implict UPNs "alice@example.com" and
"bob@example.com", respectively. If Bob's UPN gets set to
"alice@example.com", it will clash with Alice's implicit one.

Therefore we refuse to allow a UPN that implies an existing SAM account
name and vice versa.

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>
2 years agoCVE-2020-25722 s4/dsdb/samldb: unique_attr_check uses samldb_get_single_valued_attr()
Douglas Bagnall [Fri, 22 Oct 2021 00:16:30 +0000 (13:16 +1300)]
CVE-2020-25722 s4/dsdb/samldb: unique_attr_check uses samldb_get_single_valued_attr()

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>
2 years agoCVE-2020-25722 s4/dsdb/samldb: add samldb_get_single_valued_attr() helper
Douglas Bagnall [Fri, 22 Oct 2021 01:12:25 +0000 (14:12 +1300)]
CVE-2020-25722 s4/dsdb/samldb: add samldb_get_single_valued_attr() helper

This takes a string of logic out of samldb_unique_attr_check() that we
are going to need in other places, and that would be very tedious to
repeat.

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>
2 years agoCVE-2020-25722 s4/cracknames: add comment pointing to samldb spn handling
Douglas Bagnall [Thu, 12 Aug 2021 09:53:16 +0000 (21:53 +1200)]
CVE-2020-25722 s4/cracknames: add comment pointing to samldb spn handling

These need to stay a little bit in sync. The reverse comment is there.

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>
2 years agoCVE-2020-25722 pytest: test setting servicePrincipalName over ldap
Douglas Bagnall [Fri, 6 Aug 2021 00:03:18 +0000 (12:03 +1200)]
CVE-2020-25722 pytest: test setting servicePrincipalName over ldap

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>
2 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>
2 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>
2 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>