bbaumbach/samba-autobuild/.git
22 months agolibcli:auth: Add decode_pwd_string_from_buffer514()
Andreas Schneider [Mon, 23 Aug 2021 13:03:19 +0000 (15:03 +0200)]
libcli:auth: Add decode_pwd_string_from_buffer514()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos4:rpc_server: Implement support for SAMR SetUserInfo(2) level 31
Andreas Schneider [Wed, 18 Aug 2021 14:22:19 +0000 (16:22 +0200)]
s4:rpc_server: Implement support for SAMR SetUserInfo(2) level 31

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos4:rpc_server: Add samr_set_password_aes()
Andreas Schneider [Wed, 18 Aug 2021 14:21:59 +0000 (16:21 +0200)]
s4:rpc_server: Add samr_set_password_aes()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos4:rpc_server: Add transaction for dcesrv_samr_SetUserInfo()
Andreas Schneider [Tue, 26 Jul 2022 09:04:29 +0000 (11:04 +0200)]
s4:rpc_server: Add transaction for dcesrv_samr_SetUserInfo()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos4:rpc_server: Use sam_ctx consistently in dcesrv_samr_SetUserInfo()
Andreas Schneider [Tue, 26 Jul 2022 08:59:13 +0000 (10:59 +0200)]
s4:rpc_server: Use sam_ctx consistently in dcesrv_samr_SetUserInfo()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3:rpc_server: Use a done goto label for dcesrv_samr_SetUserInfo()
Andreas Schneider [Tue, 26 Jul 2022 08:57:19 +0000 (10:57 +0200)]
s3:rpc_server: Use a done goto label for dcesrv_samr_SetUserInfo()

This will be used in the following commits.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agolibcli:auth: Add test for extract_pwd_blob_from_buffer514()
Andreas Schneider [Mon, 25 Jul 2022 10:06:05 +0000 (12:06 +0200)]
libcli:auth: Add test for extract_pwd_blob_from_buffer514()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agolibcli:auth: Add extract_pwd_blob_from_buffer514()
Andreas Schneider [Fri, 20 Aug 2021 07:45:27 +0000 (09:45 +0200)]
libcli:auth: Add extract_pwd_blob_from_buffer514()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agolibcli:auth: Implment a common create_pw_buffer_from_blob()
Andreas Schneider [Mon, 25 Jul 2022 08:29:01 +0000 (10:29 +0200)]
libcli:auth: Implment a common create_pw_buffer_from_blob()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agolibcli:auth: Use extract_pw_from_buffer() in decode_pw_buffer()
Andreas Schneider [Mon, 25 Jul 2022 08:14:12 +0000 (10:14 +0200)]
libcli:auth: Use extract_pw_from_buffer() in decode_pw_buffer()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agolibcli:auth: Keep data of extract_pw_from_buffer() secret
Andreas Schneider [Mon, 25 Jul 2022 06:42:39 +0000 (08:42 +0200)]
libcli:auth: Keep data of extract_pw_from_buffer() secret

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3:rpcclient: Implement setuserinfo2 level 31
Andreas Schneider [Mon, 2 Aug 2021 13:41:23 +0000 (15:41 +0200)]
s3:rpcclient: Implement setuserinfo2 level 31

Manually tested against Windows Server 2022.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3:rpcclient: Encrypt the password buffers only if really needed
Andreas Schneider [Mon, 18 Jul 2022 13:48:36 +0000 (15:48 +0200)]
s3:rpcclient: Encrypt the password buffers only if really needed

If we are in FIPS mode certain ciphers like RC4 are not available, so
we should make sure we do not call them. We will add AES support in the
next patch.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agos3:rpc_client: Implement init_samr_CryptPasswordAES()
Andreas Schneider [Fri, 30 Jul 2021 14:24:37 +0000 (16:24 +0200)]
s3:rpc_client: Implement init_samr_CryptPasswordAES()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agosamr.idl: Add samr_ChangePasswordUser4()
Andreas Schneider [Thu, 26 Aug 2021 15:37:59 +0000 (17:37 +0200)]
samr.idl: Add samr_ChangePasswordUser4()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agosamr:idl: add samr_SupportedFeatures for samr_Connect5()
Andreas Schneider [Wed, 25 Aug 2021 12:11:28 +0000 (14:11 +0200)]
samr:idl: add samr_SupportedFeatures for samr_Connect5()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agosamr.idl: Add support for new AES encrypted password buffer
Andreas Schneider [Fri, 30 Jul 2021 09:12:07 +0000 (11:12 +0200)]
samr.idl: Add support for new AES encrypted password buffer

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agolibcli:auth: Add test for encode_pwd_buffer514_from_str()
Andreas Schneider [Mon, 25 Jul 2022 09:25:09 +0000 (11:25 +0200)]
libcli:auth: Add test for encode_pwd_buffer514_from_str()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agolibcli:auth: Add encode_pw_buffer_from_str()
Andreas Schneider [Thu, 19 Aug 2021 09:29:04 +0000 (11:29 +0200)]
libcli:auth: Add encode_pw_buffer_from_str()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agolibcli:auth: Implement a generic encode_pwd_buffer_from_str()
Andreas Schneider [Fri, 22 Jul 2022 12:26:43 +0000 (14:26 +0200)]
libcli:auth: Implement a generic encode_pwd_buffer_from_str()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agolibcli:auth: Remove trailing spaces from proto.h
Andreas Schneider [Thu, 19 Aug 2021 09:28:37 +0000 (11:28 +0200)]
libcli:auth: Remove trailing spaces from proto.h

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agolib:crypto: Add test for samba_gnutls_aead_aes_256_cbc_hmac_sha512_decrypt()
Andreas Schneider [Tue, 17 Aug 2021 09:19:01 +0000 (11:19 +0200)]
lib:crypto: Add test for samba_gnutls_aead_aes_256_cbc_hmac_sha512_decrypt()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agolib:crypto: Add samba_gnutls_aead_aes_256_cbc_hmac_sha512_decrypt()
Andreas Schneider [Mon, 16 Aug 2021 15:14:19 +0000 (17:14 +0200)]
lib:crypto: Add samba_gnutls_aead_aes_256_cbc_hmac_sha512_decrypt()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agolib:crypto: Add test for samba_gnutls_aead_aes_256_cbc_hmac_sha512_encrypt()
Andreas Schneider [Tue, 3 Aug 2021 12:14:07 +0000 (14:14 +0200)]
lib:crypto: Add test for samba_gnutls_aead_aes_256_cbc_hmac_sha512_encrypt()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agolibrpc:rpc: Add SAMR encryption and mac key salt definitions
Andreas Schneider [Mon, 18 Jul 2022 11:42:07 +0000 (13:42 +0200)]
librpc:rpc: Add SAMR encryption and mac key salt definitions

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agolib:crypto: Implement samba_gnutls_aead_aes_256_cbc_hmac_sha512_encrypt()
Andreas Schneider [Mon, 2 Aug 2021 14:21:19 +0000 (16:21 +0200)]
lib:crypto: Implement samba_gnutls_aead_aes_256_cbc_hmac_sha512_encrypt()

This is for [MS-SAMR] 3.2.2.4 AES Cipher Usage

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agolib:replace: Add macros to burn data from memory
Andreas Schneider [Tue, 19 Jul 2022 11:36:57 +0000 (13:36 +0200)]
lib:replace: Add macros to burn data from memory

This will explicitly zero data from memory. This is guaranteed to be not
optimized away.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agolib:crypto: Merge wscript_build into wscript
Andreas Schneider [Mon, 2 Aug 2021 14:34:05 +0000 (16:34 +0200)]
lib:crypto: Merge wscript_build into wscript

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agolib:crypto: Merge wscript_configure into wscript
Andreas Schneider [Mon, 2 Aug 2021 14:28:53 +0000 (16:28 +0200)]
lib:crypto: Merge wscript_configure into wscript

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agolib:crypto: Reformat wscript
Andreas Schneider [Mon, 2 Aug 2021 14:27:04 +0000 (16:27 +0200)]
lib:crypto: Reformat wscript

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
22 months agoctdb-tests: Add tests for cluster mutex I/O timeout
Martin Schwenke [Fri, 25 Feb 2022 08:44:52 +0000 (19:44 +1100)]
ctdb-tests: Add tests for cluster mutex I/O timeout

Block the locker helper child by taking a lock on the 2nd byte of the
lock file.  This will cause a ping timeout if the process is blocked
for long enough.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Thu Jul 28 11:10:54 UTC 2022 on sn-devel-184

22 months agoctdb-tests: Terminate event loop if lock is no longer held
Martin Schwenke [Mon, 28 Feb 2022 05:11:18 +0000 (16:11 +1100)]
ctdb-tests: Terminate event loop if lock is no longer held

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
22 months agoctdb-mutex: Test the lock by locking a 2nd byte range
Martin Schwenke [Tue, 8 Feb 2022 01:23:42 +0000 (12:23 +1100)]
ctdb-mutex: Test the lock by locking a 2nd byte range

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
22 months agoctdb-mutex: open() and fstat() when testing lock file
Martin Schwenke [Tue, 8 Feb 2022 01:15:26 +0000 (12:15 +1100)]
ctdb-mutex: open() and fstat() when testing lock file

This makes a file descriptor available for other I/O.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
22 months agoctdb-mutex: Factor out function fcntl_lock_fd()
Martin Schwenke [Tue, 8 Feb 2022 00:56:46 +0000 (11:56 +1100)]
ctdb-mutex: Factor out function fcntl_lock_fd()

Allows blocking mode and start offset to be specified.  Always locks a
1-byte range.

Make the lock structure static to avoid initialising the whole
structure each time.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
22 months agoctdb-mutex: Handle pings from lock checking child to parent
Martin Schwenke [Fri, 28 Jan 2022 02:49:48 +0000 (13:49 +1100)]
ctdb-mutex: Handle pings from lock checking child to parent

The ping timeout is specified by passing an extra argument to the
mutex helper, representing the ping timeout in seconds.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
22 months agoctdb-mutex: Do inode checks in a child process
Martin Schwenke [Fri, 21 Jan 2022 02:37:17 +0000 (13:37 +1100)]
ctdb-mutex: Do inode checks in a child process

In future this will allow extra I/O tests and a timeout in the parent
to (hopefully) release the lock if the child gets wedged.  For
simplicity, use tmon only to detect when either parent or child goes
away.  Plumbing a timeout for pings from child to parent will be done
later.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
22 months agoctdb-mutex: Rename wait_for_lost to lock_io_check
Martin Schwenke [Mon, 7 Feb 2022 22:35:17 +0000 (09:35 +1100)]
ctdb-mutex: Rename wait_for_lost to lock_io_check

This will be generalised to do more I/O-based checks.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
22 months agoctdb-mutex: Rename recheck_time to recheck_interval
Martin Schwenke [Wed, 19 Jan 2022 01:09:07 +0000 (12:09 +1100)]
ctdb-mutex: Rename recheck_time to recheck_interval

There will be more timeouts so clarify the intent of this one.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
22 months agoctdb-mutex: Consistently use progname in error messages
Martin Schwenke [Mon, 28 Feb 2022 22:58:22 +0000 (09:58 +1100)]
ctdb-mutex: Consistently use progname in error messages

To avoid error messages having ridiculously long paths, set progname
to basename(argv[0]).

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
22 months agoctdb-tests: Add tests for trivial FD monitoring
Martin Schwenke [Wed, 2 Feb 2022 10:47:59 +0000 (21:47 +1100)]
ctdb-tests: Add tests for trivial FD monitoring

tmon_ping_test covers complex 2-way interaction between processes
using tmon_ping_send(), including via a socketpair().  tmon_test
covers the more general functionality of tmon_send() but uses a
simpler 1-way harness with wide coverage.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
22 months agoctdb-common: Add trivial FD monitoring abstraction
Martin Schwenke [Tue, 1 Feb 2022 00:44:48 +0000 (11:44 +1100)]
ctdb-common: Add trivial FD monitoring abstraction

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
22 months agoctdb-build: Link in backtrace support for ctdb_util_tests
Martin Schwenke [Tue, 3 May 2022 23:21:38 +0000 (09:21 +1000)]
ctdb-build: Link in backtrace support for ctdb_util_tests

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
22 months agoctdb-build: Separate test backtrace support into separate subsystem
Martin Schwenke [Tue, 3 May 2022 23:02:12 +0000 (09:02 +1000)]
ctdb-build: Separate test backtrace support into separate subsystem

A convention when testing members of ctdb-util is to include the .c
file so that static functions can potentially be tested.  This means
that such tests can't be linked against ctdb-util or duplicate symbols
will be encountered.

ctdb-tests-common depends on ctdb-client, which depends in turn on
ctdb-util, so this can't be used to pull in backtrace support.
Instead, make ctdb-tests-backtrace its own subsystem.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
22 months agoctdb-build: Sort sources in ctdb-util and ctdb_unit_tests
Martin Schwenke [Tue, 3 May 2022 23:17:40 +0000 (09:17 +1000)]
ctdb-build: Sort sources in ctdb-util and ctdb_unit_tests

Also, rename ctdb_unit_tests to ctdb_util_tests.  The sorting makes
it clear that only items from ctdb-util are tested here.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
22 months agoctdb-daemon: Fix printing of tickle ACKs
Martin Schwenke [Tue, 5 Jul 2022 09:33:15 +0000 (19:33 +1000)]
ctdb-daemon: Fix printing of tickle ACKs

Commit f5a20377347aba18700d010d4201775fc83a0b1b arguably got this
back-to-front:

  2022-07-27T09:50:01.985857+10:00 testn1 ctdbd[17820]: ../../ctdb/server/ctdb_takeover.c:514 sending TAKE_IP for '10.0.1.173'
  2022-07-27T09:50:01.990601+10:00 testn1 ctdbd[17820]: Send TCP tickle ACK: 10.0.1.77:33004 -> 10.0.1.173:2049
  2022-07-27T09:50:01.991323+10:00 testn1 ctdb-takeover[19758]: TAKEOVER_IP 10.0.1.173 succeeded on node 0

Unfortunately there is an inconsistency somewhere in the connection
tracking code used for tickle ACKs, making this less than obvious.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Thu Jul 28 09:02:08 UTC 2022 on sn-devel-184

22 months agopy/uptodateness: more details in missing dn report
Douglas Bagnall [Mon, 11 Jul 2022 00:06:54 +0000 (12:06 +1200)]
py/uptodateness: more details in missing dn report

This does not fix bug 15127, but it improves reporting.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Thu Jul 28 06:18:43 UTC 2022 on sn-devel-184

22 months agoutil/genrand: don't ignore errors in random number generation
Douglas Bagnall [Sun, 4 Aug 2019 12:10:53 +0000 (00:10 +1200)]
util/genrand: don't ignore errors in random number generation

In this case it is probably better to crash out.

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

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agos3: smbd: Convert call_nt_transact_create() to use filename_convert_dirfsp().
Jeremy Allison [Mon, 25 Jul 2022 23:30:06 +0000 (16:30 -0700)]
s3: smbd: Convert call_nt_transact_create() to use filename_convert_dirfsp().

One less use of filename_convert().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Jul 27 17:49:51 UTC 2022 on sn-devel-184

22 months agos3: smbd: Inside filename_convert_dirfsp_nosymlink() ensure the returned smb_fname...
Jeremy Allison [Tue, 26 Jul 2022 21:34:27 +0000 (14:34 -0700)]
s3: smbd: Inside filename_convert_dirfsp_nosymlink() ensure the returned smb_fname is always allocated off mem_ctx.

Without this, if we just return smb_fname_rel->fsp->fsp_name as the smb_fname
then we return something allocated off fsp (which itself is allocated off
the conn struct), not the passed in talloc_ctx.

Do this for both non-stream and stream returns.

This matters for two reasons.

1). If we error out after calling filename_convert_dirfsp()
but before getting to the code inside create_file_unixpath()
that takes ownership of the passed in smb_fname->fsp we will
leak the fsp as the destructor for smb_fname that closes the
fsp will never fire on return to the client, as smb_fname is
owned by smb_fname->fsp, not the talloc_tos() context.

2). Some uses of filename_convert() expect to be able
to TALLOC_FREE the returned smb_fname once they've successfully
called SMB_VFS_CREATE_FILE() as they consider the passed in smb_fname
no longer used. It would be nice to be able to just change
filename_convert() -> filename_convert_dirfsp() without
having to change the lifetime handling of smb_fname.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
22 months agos3: smbd: In openat_pathref_dirfsp_nosymlink() ensure we call fsp_smb_fname_link...
Jeremy Allison [Tue, 26 Jul 2022 21:29:21 +0000 (14:29 -0700)]
s3: smbd: In openat_pathref_dirfsp_nosymlink() ensure we call fsp_smb_fname_link() to set smb_fname->fsp in the returned smb_fname.

Instead of just assigning smb_fname->fsp = fsp.

This makes the logic match that of openat_pathref_fullname() and parent_pathref()
when returning smb_fnames with associated pathref fsp's.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
22 months agoCVE-2022-32742: s3: smbd: Harden the smbreq_bufrem() macro.
Jeremy Allison [Tue, 7 Jun 2022 16:53:08 +0000 (09:53 -0700)]
CVE-2022-32742: s3: smbd: Harden the smbreq_bufrem() macro.

Fixes the raw.write.bad-write test.

NB. We need the two (==0) changes in source3/smbd/smb2_reply.c
as the gcc optimizer now knows that the return from
smbreq_bufrem() can never be less than zero.

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

Remove knownfail.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Autobuild-User(master): Jule Anger <janger@samba.org>
Autobuild-Date(master): Wed Jul 27 11:46:46 UTC 2022 on sn-devel-184

22 months agoCVE-2022-32742: s4: torture: Add raw.write.bad-write test.
Jeremy Allison [Tue, 7 Jun 2022 16:40:45 +0000 (09:40 -0700)]
CVE-2022-32742: s4: torture: Add raw.write.bad-write test.

Reproduces the test code in:

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

Add knownfail.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
22 months agoCVE-2022-2031 testprogs: Add test for short-lived ticket across an incoming trust
Joseph Sutton [Thu, 23 Jun 2022 01:59:11 +0000 (13:59 +1200)]
CVE-2022-2031 testprogs: Add test for short-lived ticket across an incoming trust

We ensure that the KDC does not reject a TGS-REQ with our short-lived
TGT over an incoming trust.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
22 months agoCVE-2022-2031 s4:kpasswd: Do not accept TGTs as kpasswd tickets
Joseph Sutton [Fri, 10 Jun 2022 07:18:53 +0000 (19:18 +1200)]
CVE-2022-2031 s4:kpasswd: Do not accept TGTs as kpasswd tickets

If TGTs can be used as kpasswd tickets, the two-minute lifetime of a
authentic kpasswd ticket may be bypassed. Furthermore, kpasswd tickets
are not supposed to be cached, but using this flaw, a stolen credentials
cache containing a TGT may be used to change that account's password,
and thus is made more valuable to an attacker.

Since all TGTs should be issued with a REQUESTER_SID PAC buffer, and
service tickets without it, we assert the absence of this buffer to
ensure we're not accepting a TGT.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 s4:auth: Use PAC to determine whether ticket is a TGT
Joseph Sutton [Fri, 10 Jun 2022 07:18:35 +0000 (19:18 +1200)]
CVE-2022-2031 s4:auth: Use PAC to determine whether ticket is a TGT

We use the presence or absence of a REQUESTER_SID PAC buffer to
determine whether the ticket is a TGT. We will later use this to reject
TGTs where a service ticket is expected.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 auth: Add ticket type field to auth_user_info_dc and auth_session_info
Joseph Sutton [Fri, 10 Jun 2022 07:18:07 +0000 (19:18 +1200)]
CVE-2022-2031 auth: Add ticket type field to auth_user_info_dc and auth_session_info

This field may be used to convey whether we were provided with a TGT or
a non-TGT. We ensure both structures are zeroed out to avoid incorrect
results being produced by an uninitialised field.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 tests/krb5: Add test that we cannot provide a TGT to kpasswd
Joseph Sutton [Fri, 10 Jun 2022 07:17:11 +0000 (19:17 +1200)]
CVE-2022-2031 tests/krb5: Add test that we cannot provide a TGT to kpasswd

The kpasswd service should require a kpasswd service ticket, and
disallow TGTs.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-32744 s4:kpasswd: Ensure we pass the kpasswd server principal into krb5_rd_r...
Joseph Sutton [Mon, 30 May 2022 07:16:02 +0000 (19:16 +1200)]
CVE-2022-32744 s4:kpasswd: Ensure we pass the kpasswd server principal into krb5_rd_req_ctx()

To ensure that, when decrypting the kpasswd ticket, we look up the
correct principal and don't trust the sname from the ticket, we should
pass the principal name of the kpasswd service into krb5_rd_req_ctx().
However, gensec_krb5_update_internal() will pass in NULL unless the
principal in our credentials is CRED_SPECIFIED.

At present, our principal will be considered obtained as CRED_SMB_CONF
(from the cli_credentials_set_conf() a few lines up), so we explicitly
set the realm again, but this time as CRED_SPECIFIED. Now the value of
server_in_keytab that we provide to smb_krb5_rd_req_decoded() will not
be NULL.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-32744 s4:kdc: Modify HDB plugin to only look up kpasswd principal
Joseph Sutton [Thu, 26 May 2022 04:39:20 +0000 (16:39 +1200)]
CVE-2022-32744 s4:kdc: Modify HDB plugin to only look up kpasswd principal

This plugin is now only used by the kpasswd service. Thus, ensuring we
only look up the kadmin/changepw principal means we can't be fooled into
accepting tickets for other service principals. We make sure not to
specify a specific kvno, to ensure that we do not accept RODC-issued
tickets.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agos4:kdc: Remove kadmin mode from HDB plugin
Joseph Sutton [Wed, 8 Jun 2022 01:53:29 +0000 (13:53 +1200)]
s4:kdc: Remove kadmin mode from HDB plugin

It appears we no longer require it.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-32744 s4:kdc: Rename keytab_name -> kpasswd_keytab_name
Joseph Sutton [Thu, 26 May 2022 04:36:30 +0000 (16:36 +1200)]
CVE-2022-32744 s4:kdc: Rename keytab_name -> kpasswd_keytab_name

This makes explicitly clear the purpose of this keytab.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 s4:kdc: Don't use strncmp to compare principal components
Joseph Sutton [Wed, 25 May 2022 08:00:55 +0000 (20:00 +1200)]
CVE-2022-2031 s4:kdc: Don't use strncmp to compare principal components

We would only compare the first 'n' characters, where 'n' is the length
of the principal component string, so 'k@REALM' would erroneously be
considered equal to 'krbtgt@REALM'.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 tests/krb5: Test truncated forms of server principals
Joseph Sutton [Tue, 14 Jun 2022 03:23:55 +0000 (15:23 +1200)]
CVE-2022-2031 tests/krb5: Test truncated forms of server principals

We should not be able to use krb@REALM instead of krbtgt@REALM.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-32744 s4:kdc: Don't allow HDB keytab iteration
Joseph Sutton [Tue, 24 May 2022 05:52:05 +0000 (17:52 +1200)]
CVE-2022-32744 s4:kdc: Don't allow HDB keytab iteration

A fallback in krb5_rd_req_ctx() means that Samba's kpasswd service will
try many inappropriate keys to decrypt the ticket supplied to it. For
example, it will accept a ticket encrypted with the Administrator's key,
when it should rather accept only tickets encrypted with the krbtgt's
key (and not an RODC krbtgt). To fix this, declare the HDB keytab using
the HDBGET ops, which do not support iteration.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 s4:kdc: Reject tickets during the last two minutes of their life
Joseph Sutton [Mon, 30 May 2022 07:18:17 +0000 (19:18 +1200)]
CVE-2022-2031 s4:kdc: Reject tickets during the last two minutes of their life

For Heimdal, this now matches the behaviour of Windows. The object of
this requirement is to ensure we don't allow kpasswd tickets, not having
a lifetime of more than two minutes, to be passed off as TGTs.

An existing requirement for TGTs to contain a REQUESTER_SID PAC buffer
suffices to prevent kpasswd ticket misuse, so this is just an additional
precaution on top.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 third_party/heimdal: Add function to get current KDC time
Joseph Sutton [Wed, 22 Jun 2022 08:01:12 +0000 (20:01 +1200)]
CVE-2022-2031 third_party/heimdal: Add function to get current KDC time

This allows the plugin to check the endtime of a ticket against the
KDC's current time, to see if the ticket will expire in the next two
minutes.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
22 months agoCVE-2022-2031 s4:kdc: Limit kpasswd ticket lifetime to two minutes or less
Joseph Sutton [Tue, 24 May 2022 05:53:49 +0000 (17:53 +1200)]
CVE-2022-2031 s4:kdc: Limit kpasswd ticket lifetime to two minutes or less

This matches the behaviour of Windows.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 s4:kdc: Fix canonicalisation of kadmin/changepw principal
Joseph Sutton [Wed, 18 May 2022 04:56:01 +0000 (16:56 +1200)]
CVE-2022-2031 s4:kdc: Fix canonicalisation of kadmin/changepw principal

Since this principal goes through the samba_kdc_fetch_server() path,
setting the canonicalisation flag would cause the principal to be
replaced with the sAMAccountName; this meant requests to
kadmin/changepw@REALM would result in a ticket to krbtgt@REALM. Now we
properly handle canonicalisation for the kadmin/changepw principal.

View with 'git show -b'.

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

Pair-Programmed-With: Andreas Schneider <asn@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 s4:kdc: Refactor samba_kdc_get_entry_principal()
Joseph Sutton [Wed, 25 May 2022 05:19:58 +0000 (17:19 +1200)]
CVE-2022-2031 s4:kdc: Refactor samba_kdc_get_entry_principal()

This eliminates some duplicate branches.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Pair-Programmed-With: Andreas Schneider <asn@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 s4:kdc: Split out a samba_kdc_get_entry_principal() function
Joseph Sutton [Wed, 18 May 2022 04:56:01 +0000 (16:56 +1200)]
CVE-2022-2031 s4:kdc: Split out a samba_kdc_get_entry_principal() function

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 s4:kdc: Implement is_kadmin_changepw() helper function
Andreas Schneider [Tue, 24 May 2022 07:54:18 +0000 (09:54 +0200)]
CVE-2022-2031 s4:kdc: Implement is_kadmin_changepw() helper function

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
22 months agoCVE-2022-2031 testprogs: Add kadmin/changepw canonicalization test with MIT kpasswd
Andreas Schneider [Thu, 19 May 2022 14:35:28 +0000 (16:35 +0200)]
CVE-2022-2031 testprogs: Add kadmin/changepw canonicalization test with MIT kpasswd

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

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
22 months agos4:kpasswd: Restructure code for clarity
Joseph Sutton [Wed, 18 May 2022 05:11:49 +0000 (17:11 +1200)]
s4:kpasswd: Restructure code for clarity

View with 'git show -b'.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 s4:kpasswd: Require an initial ticket
Joseph Sutton [Wed, 18 May 2022 04:52:41 +0000 (16:52 +1200)]
CVE-2022-2031 s4:kpasswd: Require an initial ticket

Ensure that for password changes the client uses an AS-REQ to get the
ticket to kpasswd, and not a TGS-REQ.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 gensec_krb5: Add helper function to check if client sent an initial...
Joseph Sutton [Wed, 18 May 2022 04:06:31 +0000 (16:06 +1200)]
CVE-2022-2031 gensec_krb5: Add helper function to check if client sent an initial ticket

This will be used in the kpasswd service to ensure that the client has
an initial ticket to kadmin/changepw, and not a service ticket.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 s4:kpasswd: Return a kpasswd error code in KRB-ERROR
Joseph Sutton [Wed, 18 May 2022 04:49:43 +0000 (16:49 +1200)]
CVE-2022-2031 s4:kpasswd: Return a kpasswd error code in KRB-ERROR

If we attempt to return an error code outside of Heimdal's allowed range
[KRB5KDC_ERR_NONE, KRB5_ERR_RCSID), it will be replaced with a GENERIC
error, and the error text will be set to the meaningless result of
krb5_get_error_message(). Avoid this by ensuring the error code is in
the correct range.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15047
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15049
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15074

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 lib:krb5_wrap: Generate valid error codes in smb_krb5_mk_error()
Joseph Sutton [Fri, 27 May 2022 07:29:34 +0000 (19:29 +1200)]
CVE-2022-2031 lib:krb5_wrap: Generate valid error codes in smb_krb5_mk_error()

The error code passed in will be an offset from ERROR_TABLE_BASE_krb5,
so we need to subtract that before creating the error. Heimdal does this
internally, so it isn't needed there.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15047
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15049
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15074

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 s4:kpasswd: Don't return AP-REP on failure
Joseph Sutton [Wed, 18 May 2022 04:48:59 +0000 (16:48 +1200)]
CVE-2022-2031 s4:kpasswd: Don't return AP-REP on failure

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15047
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15049
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15074

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 s4:kpasswd: Correctly generate error strings
Joseph Sutton [Fri, 27 May 2022 07:21:06 +0000 (19:21 +1200)]
CVE-2022-2031 s4:kpasswd: Correctly generate error strings

The error_data we create already has an explicit length, and should not
be zero-terminated, so we omit the trailing null byte. Previously,
Heimdal builds would leave a superfluous trailing null byte on error
strings, while MIT builds would omit the final character.

The two bytes added to the string's length are for the prepended error
code.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15047
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15049
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15074

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 tests/krb5: Add tests for kpasswd service
Joseph Sutton [Tue, 24 May 2022 07:59:16 +0000 (19:59 +1200)]
CVE-2022-2031 tests/krb5: Add tests for kpasswd service

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15047
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15049
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15074

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 tests/krb5: Consider kadmin/* principals as TGS for MIT KRB5 >= 1.20
Joseph Sutton [Tue, 31 May 2022 07:23:06 +0000 (19:23 +1200)]
CVE-2022-2031 tests/krb5: Consider kadmin/* principals as TGS for MIT KRB5 >= 1.20

With MIT Kerberos >= 1.20, we should not expect a ticket checksum in
tickets to principals such as kpasswd/changepw, as they are encrypted
with the krbtgt's key.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15047
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15049
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15074

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-32744 selftest: Specify Administrator kvno for Python krb5 tests
Joseph Sutton [Thu, 26 May 2022 04:35:03 +0000 (16:35 +1200)]
CVE-2022-32744 selftest: Specify Administrator kvno for Python krb5 tests

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 tests/krb5: Add kpasswd_exchange() method
Joseph Sutton [Tue, 24 May 2022 07:57:57 +0000 (19:57 +1200)]
CVE-2022-2031 tests/krb5: Add kpasswd_exchange() method

Now we can test the kpasswd service from Python.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15047
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15049
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15074

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 tests/krb5: Allow requesting a TGT to a different sname and realm
Joseph Sutton [Tue, 24 May 2022 07:34:59 +0000 (19:34 +1200)]
CVE-2022-2031 tests/krb5: Allow requesting a TGT to a different sname and realm

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15047
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15049
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15074

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agotests/krb5: Add option for creating accounts with expired passwords
Joseph Sutton [Tue, 24 May 2022 07:30:12 +0000 (19:30 +1200)]
tests/krb5: Add option for creating accounts with expired passwords

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agotests/krb5: Fix enum typo
Joseph Sutton [Tue, 24 May 2022 07:26:56 +0000 (19:26 +1200)]
tests/krb5: Fix enum typo

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 tests/krb5: Add methods to send and receive generic messages
Joseph Sutton [Tue, 24 May 2022 07:20:28 +0000 (19:20 +1200)]
CVE-2022-2031 tests/krb5: Add methods to send and receive generic messages

This allows us to send and receive kpasswd messages, while avoiding the
existing logic for encoding and decoding other Kerberos message types.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15047
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15049
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15074

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 tests/krb5: Add 'port' parameter to connect()
Joseph Sutton [Tue, 24 May 2022 07:21:37 +0000 (19:21 +1200)]
CVE-2022-2031 tests/krb5: Add 'port' parameter to connect()

This allows us to use the kpasswd port, 464.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15047
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15049
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15074

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 tests/krb5: Add methods to create ASN1 kpasswd structures
Joseph Sutton [Tue, 24 May 2022 07:17:45 +0000 (19:17 +1200)]
CVE-2022-2031 tests/krb5: Add methods to create ASN1 kpasswd structures

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15047
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15049
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15074

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 tests/krb5: Add new definitions for kpasswd
Joseph Sutton [Tue, 24 May 2022 07:13:54 +0000 (19:13 +1200)]
CVE-2022-2031 tests/krb5: Add new definitions for kpasswd

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15047
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15049
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15074

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-32744 tests/krb5: Correctly calculate salt for pre-existing accounts
Joseph Sutton [Tue, 24 May 2022 07:06:53 +0000 (19:06 +1200)]
CVE-2022-32744 tests/krb5: Correctly calculate salt for pre-existing accounts

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 tests/krb5: Split out _make_tgs_request()
Joseph Sutton [Thu, 26 May 2022 08:52:04 +0000 (20:52 +1200)]
CVE-2022-2031 tests/krb5: Split out _make_tgs_request()

This allows us to make use of it in other tests.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-32744 tests/krb5: Correctly handle specifying account kvno
Joseph Sutton [Thu, 26 May 2022 04:34:01 +0000 (16:34 +1200)]
CVE-2022-32744 tests/krb5: Correctly handle specifying account kvno

The environment variable is a string, but we expect an integer.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 s4:kpasswd: Add MIT fallback for decoding setpw structure
Joseph Sutton [Mon, 30 May 2022 07:17:41 +0000 (19:17 +1200)]
CVE-2022-2031 s4:kpasswd: Add MIT fallback for decoding setpw structure

The target principal and realm fields of the setpw structure are
supposed to be optional, but in MIT Kerberos they are mandatory. For
better compatibility and ease of testing, fall back to parsing the
simpler (containing only the new password) structure if the MIT function
fails to decode it.

Although the target principal and realm fields should be optional, one
is not supposed to specified without the other, so we don't have to deal
with the case where only one is specified.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15047
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15049
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15074

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 s4:kpasswd: Account for missing target principal
Joseph Sutton [Fri, 27 May 2022 07:17:02 +0000 (19:17 +1200)]
CVE-2022-2031 s4:kpasswd: Account for missing target principal

This field is supposed to be optional.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15047
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15049
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15074

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
22 months agoCVE-2022-2031 third_party/heimdal: Check generate_pac() return code
Joseph Sutton [Thu, 16 Jun 2022 03:32:49 +0000 (15:32 +1200)]
CVE-2022-2031 third_party/heimdal: Check generate_pac() return code

If the function fails, we should not issue a ticket missing the PAC.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
22 months agoCVE-2022-32745 s4/dsdb/util: Correctly copy values into message element
Joseph Sutton [Fri, 3 Jun 2022 04:16:31 +0000 (16:16 +1200)]
CVE-2022-32745 s4/dsdb/util: Correctly copy values into message element

To use memcpy(), we need to specify the number of bytes to copy, rather
than the number of ldb_val structures.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
22 months agoCVE-2022-32745 s4/dsdb/util: Don't call memcpy() with a NULL pointer
Joseph Sutton [Wed, 16 Feb 2022 22:13:38 +0000 (11:13 +1300)]
CVE-2022-32745 s4/dsdb/util: Don't call memcpy() with a NULL pointer

Doing so is undefined behaviour.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
22 months agoCVE-2022-32745 s4/dsdb/util: Use correct value for loop count limit
Joseph Sutton [Wed, 16 Feb 2022 22:11:53 +0000 (11:11 +1300)]
CVE-2022-32745 s4/dsdb/util: Use correct value for loop count limit

Currently, we can crash the server by sending a large number of values
of a specific attribute (such as sAMAccountName) spread across a few
message elements. If val_count is larger than the total number of
elements, we get an access beyond the elements array.

Similarly, we can include unrelated message elements prior to the
message elements of the attribute in question, so that not all of the
attribute's values are copied into the returned elements values array.
This can cause the server to access uninitialised data, likely resulting
in a crash or unexpected behaviour.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>