]> git.ipfire.org Git - thirdparty/krb5.git/log
thirdparty/krb5.git
7 days agoPrevent overflow when calculating ulog block size krb5-1.21
Zoltan Borbely [Tue, 28 Jan 2025 21:39:25 +0000 (16:39 -0500)] 
Prevent overflow when calculating ulog block size

In kdb_log.c:resize(), log an error and fail if the update size is
larger than the largest possible block size (2^16-1).

CVE-2025-24528:

In MIT krb5 release 1.7 and later with incremental propagation
enabled, an authenticated attacker can cause kadmind to write beyond
the end of the mapped region for the iprop log file, likely causing a
process crash.

[ghudson@mit.edu: edited commit message and added CVE description]

(cherry picked from commit 78ceba024b64d49612375be4a12d1c066b0bfbd0)

ticket: 9159
version_fixed: 1.21.4

7 days agoFix potential PAC processing crash
Arjun [Fri, 11 Oct 2024 03:22:52 +0000 (08:52 +0530)] 
Fix potential PAC processing crash

An input to krb5_pac_parse() with a zero-length buffer at the end of
the PAC can cause an assertion failure in k5_pac_locate_buffer() due
to an off-by-one error.  Correct the assertion.

[ghudson@mit.edu: edited commit message]

(cherry picked from commit 331e393c6def46c00b6b54e1b2a0d1080c2af9e0)

ticket: 9144
version_fixed: 1.21.4

7 days agoFix memory leak in PAC checksum verification
Arjun [Thu, 10 Oct 2024 19:25:59 +0000 (00:55 +0530)] 
Fix memory leak in PAC checksum verification

If the server checksum length is invalid, do proper cleanup in
verify_pac_checksums() before returning.

[ghudson@mit.edu: edited commit message]

(cherry picked from commit c03ac354436a7182962b4987d318a86cb7ac558b)

ticket: 9143
version_fixed: 1.21.4

7 days agoGenerate and verify message MACs in libkrad
Julien Rische [Thu, 22 Aug 2024 15:15:50 +0000 (17:15 +0200)] 
Generate and verify message MACs in libkrad

Implement some of the measures specified in
draft-ietf-radext-deprecating-radius-03 for mitigating the BlastRADIUS
attack (CVE-2024-3596):

* Include a Message-Authenticator MAC as the first attribute when
  generating a packet of type Access-Request, Access-Reject,
  Access-Accept, or Access-Challenge (sections 5.2.1 and 5.2.4), if
  the secret is non-empty.  (An empty secret indicates the use of Unix
  domain socket transport.)

* Validate the Message-Authenticator MAC in received packets, if
  present.

FreeRADIUS enforces Message-Authenticator as of versions 3.2.5 and
3.0.27.  libkrad must generate Message-Authenticator attributes in
order to remain compatible with these implementations.

[ghudson@mit.edu: adjusted style and naming; simplified some
functions; edited commit message]

(cherry picked from commit 871125fea8ce0370a972bf65f7d1de63f619b06c)

ticket: 9142
version_fixed: 1.21.4

7 days agoFix krb5_crypto_us_timeofday() microseconds check
Alexey Tikhonov [Thu, 3 Oct 2024 16:40:04 +0000 (18:40 +0200)] 
Fix krb5_crypto_us_timeofday() microseconds check

Commit a60db180211a383bd382afe729e9309acb8dcf53 mistakenly reversed
the sense of the krb5_crypto_us_timeofday() conditional that enforces
fowards movement of the microseconds value within a second.  Moreover,
the macros ts_after() and ts_incr() should not have been applied to
non-timestamp values.  Revert the incorrect changes.

[ghudson@mit.edu: rewrote commit message]

(cherry picked from commit 6f6d795be8d0dd0a46952cf8afa59b65d71df744)

ticket: 9141
version_fixed: 1.21.4

11 months agoDocument dns_lookup_realm relation
Greg Hudson [Mon, 5 Aug 2024 21:37:06 +0000 (17:37 -0400)] 
Document dns_lookup_realm relation

(cherry picked from commit bcc0dda256b184f8d87a4587f3f3997770020c87)

ticket: 9134
version_fixed: 1.21.4

13 months agoUpdate for krb5-1.21.3-postrelease
Greg Hudson [Wed, 26 Jun 2024 22:10:47 +0000 (18:10 -0400)] 
Update for krb5-1.21.3-postrelease

13 months agoUpdate for krb5-1.21.3 krb5-1.21.3-final
Greg Hudson [Wed, 26 Jun 2024 17:19:09 +0000 (13:19 -0400)] 
Update for krb5-1.21.3

13 months agomake regen
Greg Hudson [Wed, 26 Jun 2024 16:58:55 +0000 (12:58 -0400)] 
make regen

13 months agoFix vulnerabilities in GSS message token handling
Greg Hudson [Fri, 14 Jun 2024 14:56:12 +0000 (10:56 -0400)] 
Fix vulnerabilities in GSS message token handling

In gss_krb5int_unseal_token_v3() and gss_krb5int_unseal_v3_iov(),
verify the Extra Count field of CFX wrap tokens against the encrypted
header.  Reported by Jacob Champion.

In gss_krb5int_unseal_token_v3(), check for a decrypted plaintext
length too short to contain the encrypted header and extra count
bytes.  Reported by Jacob Champion.

In kg_unseal_iov_token(), separately track the header IOV length and
complete token length when parsing the token's ASN.1 wrapper.  This
fix contains modified versions of functions from k5-der.h and
util_token.c; this duplication will be cleaned up in a future commit.

CVE-2024-37370:

In MIT krb5 release 1.3 and later, an attacker can modify the
plaintext Extra Count field of a confidential GSS krb5 wrap token,
causing the unwrapped token to appear truncated to the application.

CVE-2024-37371:

In MIT krb5 release 1.3 and later, an attacker can cause invalid
memory reads by sending message tokens with invalid length fields.

(cherry picked from commit b0a2f8a5365f2eec3e27d78907de9f9d2c80505a)

ticket: 9128
version_fixed: 1.21.3

13 months agoFix formatting error in realm_config.rst
Jon Moore [Sat, 25 May 2024 21:15:08 +0000 (17:15 -0400)] 
Fix formatting error in realm_config.rst

Commit 10eb93809b1af06e2b1147aee2e3e50058ba1bbd introduced a
formatting error in the SRV record descriptions.  Fix it now.

[ghudson@mit.edu: wrote commit message]

(cherry picked from commit c5772bc916f8818070f9d78a2999bd5dfa0a68d5)

ticket: 9125
version_fixed: 1.21.3

13 months agoFix leak in KDC NDR encoding
Greg Hudson [Tue, 5 Mar 2024 22:38:49 +0000 (17:38 -0500)] 
Fix leak in KDC NDR encoding

If the KDC tries to encode a principal containing encode invalid UTF-8
sequences for inclusion in a PAC delegation info buffer, it will leak
a small amount of memory in enc_wchar_pointer() before failing.  Fix
the leak.

(cherry picked from commit 7d0d85bf99caf60c0afd4dcf91b0c4c683b983fe)

ticket: 9115
version_fixed: 1.21.3

13 months agoFix memory leak in macOS 11 ccache client
Anthony Sottile [Sat, 13 Jan 2024 00:10:03 +0000 (19:10 -0500)] 
Fix memory leak in macOS 11 ccache client

In get_primary_name(), use the proper function to free conn.

[ghudson@mit.edu: wrote commit message]

(cherry picked from commit 52fe67623b7205d91ceac855651e8c17f56b10c8)

ticket: 9109
version_fixed: 1.21.3

13 months agoIn PKINIT, check for null PKCS7 enveloped fields
Greg Hudson [Sat, 25 Nov 2023 16:04:56 +0000 (11:04 -0500)] 
In PKINIT, check for null PKCS7 enveloped fields

The PKCS7 ContentInfo content field and EncryptedContentInfo
encryptedContent field are optional.  Check for null values in
cms_envelopeddata_verify() before calling pkcs7_decrypt().  Reported
by Bahaa Naamneh.

(cherry picked from commit 48ccd81656381522d1f9ccb8705c13f0266a46ab)

ticket: 9107
version_fixed: 1.21.3

13 months agoWork around Doxygen 1.9.7 change
Greg Hudson [Wed, 13 Sep 2023 21:57:01 +0000 (17:57 -0400)] 
Work around Doxygen 1.9.7 change

Doxygen 1.9.7 avoids duplicating member definitions in the XML
documents for groups and header files (doxygen/doxygen#9797).  This
change breaks the current Doxygen-REST bridge, which expects to find
memberdef elements in krb5_8hin.xml.  To work around this problem,
remove the @group and @ref declarations in krb5.hin; they were not
translated into REST as it was.

Also remove a deprecated setting in Doxyfile.

(cherry picked from commit 6ed1f8e27eb624710c4aa152d8dee4cf2e528082)

ticket: 9104
version_fixed: 1.21.3

13 months agoFix krb5_cccol_have_content() bad pointer free
Ilya Gladyshev [Wed, 30 Aug 2023 20:19:59 +0000 (21:19 +0100)] 
Fix krb5_cccol_have_content() bad pointer free

krb5_cccol_have_content() calls krb5_cc_get_principal() within a loop,
and frees the resulting principal on success or failure.  Set princ to
null before each call to ensure we don't free a dangling pointer.

[ghudson@mit.edu: rewrote commit message; moved assignment for greater
clarity]

(cherry picked from commit 635c8cca65b745476d07c1f5ff701445db25c10d)

ticket: 9103
version_fixed: 1.21.3

13 months agoEliminate sim_client include of getopt.h
Michael Osipov [Tue, 22 Aug 2023 08:05:24 +0000 (10:05 +0200)] 
Eliminate sim_client include of getopt.h

Commit 9139a60c94c24e41109574e84e7cda9c2dc3fb38 added an unconditional
include of getopt.h, which is non-portable (it isn't present on HP-UX)
and unecessary for getopt().  The same commit also disabled the
include of unistd.h (which is necessary for getopt()), as sim_client
no longer indirectly includes autoconf.  Make the unistd.h include
unconditional and remove the getopt.h include.

[ghudson@mit.edu: edited commit message]

(cherry picked from commit a6abaaf54925a4b63aff8c81da1a0af3a7c03466)

ticket: 9102
version_fixed: 1.21.3

13 months agoUpdate copyright years to 2024
Greg Hudson [Mon, 24 Jun 2024 23:28:54 +0000 (19:28 -0400)] 
Update copyright years to 2024

19 months agoBack to krb5-1.21-postrelease
Greg Hudson [Mon, 8 Jan 2024 20:32:07 +0000 (15:32 -0500)] 
Back to krb5-1.21-postrelease

19 months agoUpdates for kfw-4.3-beta1 kfw-4.3-beta1
Greg Hudson [Mon, 8 Jan 2024 16:34:25 +0000 (11:34 -0500)] 
Updates for kfw-4.3-beta1

19 months agoUpdates for kfw-4.3-beta1-mit kfw-4.3-beta1-mit
Greg Hudson [Fri, 29 Dec 2023 22:02:27 +0000 (17:02 -0500)] 
Updates for kfw-4.3-beta1-mit

23 months agoUpdate for krb5-1.21.2 1313/head krb5-1.21.2-final
Greg Hudson [Mon, 14 Aug 2023 16:16:04 +0000 (12:16 -0400)] 
Update for krb5-1.21.2

23 months agoFix double-free in KDC TGS processing
Andreas Schneider [Fri, 4 Aug 2023 07:54:06 +0000 (09:54 +0200)] 
Fix double-free in KDC TGS processing

When issuing a ticket for a TGS renew or validate request, copy only
the server field from the outer part of the header ticket to the new
ticket.  Copying the whole structure causes the enc_part pointer to be
aliased to the header ticket until krb5_encrypt_tkt_part() is called,
resulting in a double-free if handle_authdata() fails.

[ghudson@mit.edu: changed the fix to avoid aliasing enc_part rather
than check for aliasing before freeing; rewrote commit message]

CVE-2023-39975:

In MIT krb5 release 1.21, an authenticated attacker can cause a KDC to
free the same pointer twice if it can induce a failure in
authorization data handling.

(cherry picked from commit 88a1701b423c13991a8064feeb26952d3641d840)

ticket: 9101
version_fixed: 1.21.2

2 years agoUpdate for krb5-1.21.1-postrelease
Greg Hudson [Wed, 12 Jul 2023 05:51:09 +0000 (01:51 -0400)] 
Update for krb5-1.21.1-postrelease

2 years agoUpdate for krb5-1.21.1 krb5-1.21.1-final
Greg Hudson [Mon, 10 Jul 2023 20:54:53 +0000 (16:54 -0400)] 
Update for krb5-1.21.1

2 years agoEnsure array count consistency in kadm5 RPC
Greg Hudson [Wed, 21 Jun 2023 14:57:39 +0000 (10:57 -0400)] 
Ensure array count consistency in kadm5 RPC

In _xdr_kadm5_principal_ent_rec(), ensure that n_key_data matches the
key_data array count when decoding.  Otherwise when the structure is
later freed, xdr_array() could iterate over the wrong number of
elements, either leaking some memory or freeing uninitialized
pointers.  Reported by Robert Morris.

CVE-2023-36054:

An authenticated attacker can cause a kadmind process to crash by
freeing uninitialized pointers.  Remote code execution is unlikely.
An attacker with control of a kadmin server can cause a kadmin client
to crash by freeing uninitialized pointers.

(cherry picked from commit ef08b09c9459551aabbe7924fb176f1583053cdd)

ticket: 9099
version_fixed: 1.21.1

2 years agoUpdate for krb5-1.21-postrelease
Greg Hudson [Tue, 6 Jun 2023 05:08:59 +0000 (01:08 -0400)] 
Update for krb5-1.21-postrelease

2 years agoUpdate for krb5-1.21 krb5-1.21-final
Greg Hudson [Mon, 5 Jun 2023 21:33:15 +0000 (17:33 -0400)] 
Update for krb5-1.21

2 years agoUpdate for krb5-1.21-beta1-postrelease
Greg Hudson [Mon, 17 Apr 2023 15:50:08 +0000 (11:50 -0400)] 
Update for krb5-1.21-beta1-postrelease

2 years agoUpdate for krb5-1.21-beta1 krb5-1.21-beta1
Greg Hudson [Mon, 17 Apr 2023 14:26:57 +0000 (10:26 -0400)] 
Update for krb5-1.21-beta1

2 years agoUpdate README for krb5-1.21
Greg Hudson [Thu, 13 Apr 2023 22:44:26 +0000 (18:44 -0400)] 
Update README for krb5-1.21

2 years agomake regen
Greg Hudson [Thu, 13 Apr 2023 21:39:45 +0000 (17:39 -0400)] 
make regen

2 years agoUpdate config.guess, config.sub
Greg Hudson [Thu, 13 Apr 2023 21:01:44 +0000 (17:01 -0400)] 
Update config.guess, config.sub

2 years agoUpdate features list for 1.21
Greg Hudson [Thu, 13 Apr 2023 16:27:03 +0000 (12:27 -0400)] 
Update features list for 1.21

2 years agoConvey realm names to certauth modules 1296/head
Greg Hudson [Wed, 29 Mar 2023 14:15:35 +0000 (10:15 -0400)] 
Convey realm names to certauth modules

In the certauth pluggable interface, add an extended init method which
receives the realm list.

ticket: 9090 (new)

2 years agoAdd PA-REDHAT-PASSKEY padata type 1297/head
Pavel Březina [Wed, 29 Mar 2023 08:56:06 +0000 (10:56 +0200)] 
Add PA-REDHAT-PASSKEY padata type

Recognize the Red Hat passkey preauth mechanism in trace messages, and
add a declaration for it in krb5.h.

[ghudson@mit.edu: edited comment and commit message]

ticket: 9093 (new)

2 years agoAdd GSS_C_INQ_ODBC_SESSION_KEY 1298/head
Greg Hudson [Mon, 3 Apr 2023 15:27:02 +0000 (11:27 -0400)] 
Add GSS_C_INQ_ODBC_SESSION_KEY

The Oracle database wire protocol contains a cipher reinitialization
operation using the ticket session key.  Add a query operation
(similar to GSS_C_INQ_SSPI_SESSION_KEY) to retrieve the ticket session
key rather than the subkey.

ticket: 9091 (new)

2 years agoUpdate ax-pthread.m4 from autoconf archive 1299/head
Greg Hudson [Thu, 6 Apr 2023 23:26:46 +0000 (19:26 -0400)] 
Update ax-pthread.m4 from autoconf archive

Fixes a warning from autoconf 2.70 that $as_echo is obsolete.

2 years agoRun Github Actions on ubuntu-latest (not 18.04)
Greg Hudson [Mon, 3 Apr 2023 20:00:37 +0000 (16:00 -0400)] 
Run Github Actions on ubuntu-latest (not 18.04)

The ubuntu-18.04 image no longer works on Github Actions.  Run most
jobs on ubuntu-latest instead.

libresolv-wrapper does not work on ubuntu-22.04 at this time
(Launchpad bug #2015570), so don't install it for now.  The URI
discovery tests will be skipped until this is rectified.

For the doc build, move doc-newest-sphix to ubuntu-latest; the Ubuntu
version doesn't matter much for this build as it downloads sphinx from
pypi.org.  Move the doc-older-sphinx to ubuntu-22.04 (currently the
same as ubuntu-latest), skipping ubuntu-20.04 as its version of
doxygen (1.18.17) doesn't correctly the type declaration for
krb5_const_principal.

2 years agoSquash unused variable warnings in kdb5_ldap_util
Greg Hudson [Tue, 4 Apr 2023 21:31:00 +0000 (17:31 -0400)] 
Squash unused variable warnings in kdb5_ldap_util

2 years agoSquash a Berkeley DB warning
Greg Hudson [Tue, 4 Apr 2023 18:23:19 +0000 (14:23 -0400)] 
Squash a Berkeley DB warning

In __delpair(), the assignment to next_key is not used unless DEBUG is
defined, and the debugging assert can never fail--next_realkey() will
always return n + 1 as we just checked KEY_OFF(pagep, n + 1).  Remove
the variable, the assert, and the otherwise unused next_realkey()
function.  This change eliminates a warning issued by clang 14.

2 years agoFix indentation in x-deltat.y
Greg Hudson [Mon, 3 Apr 2023 23:39:04 +0000 (19:39 -0400)] 
Fix indentation in x-deltat.y

clang 14 issues a warning for having the next line at the same
indentation level as the if body.

2 years agoFix maintainer-mode build for binutils 2.37
Greg Hudson [Mon, 3 Apr 2023 23:19:38 +0000 (19:19 -0400)] 
Fix maintainer-mode build for binutils 2.37

binutils 2.37 makes --with-symbol-versions the default for nm.  In
export-check.pl, remove the default symbol versions in the nm output
if they are present.

ticket: 9092 (new)

2 years agoAdd pac_privsvr_enctype string attribute
Greg Hudson [Tue, 21 Mar 2023 04:51:17 +0000 (00:51 -0400)] 
Add pac_privsvr_enctype string attribute

The KDC uses the first local TGT key for the privsvr and full PAC
checksums.  If this key is of an aes-sha2 enctype in a cross-realm
TGT, a Microsoft KDC in the target realm may reject the ticket because
it has an unexpectedly large privsvr checksum buffer.  This behavior
is unnecessarily picky as the target realm KDC cannot and does not
need to very the privsvr checksum, but [MS-PAC] 2.8.2 does limit the
checksum key to three specific enctypes.

As a workaround, add a string attribute which can force the privsvr
key to use a specified enctype using key derivation when issuing
tickets to that principal.  This attribute can be set on cross-realm
TGT entries when the target realm uses Active Directory and the local
TGT uses an aes-sha2 primary key.

ticket: 9089 (new)

2 years agoFix potential memory leak in recent commit 1268/head
Greg Hudson [Sun, 26 Mar 2023 05:32:57 +0000 (01:32 -0400)] 
Fix potential memory leak in recent commit

In get_negTokenInit(), reject a zero-length mechTypes field before
copying it into *der_mechSet, to prevent allocating a zero-length GSS
buffer.

2 years agoEliminate TWRITE macros in GSS library 1291/head
Greg Hudson [Wed, 15 Mar 2023 20:23:09 +0000 (16:23 -0400)] 
Eliminate TWRITE macros in GSS library

Use dynamic k5buf structures to replace the two uses of the TWRITE_
macros, and replace the uses of TREAD_ macros with the equivalent
pointer assignments.

2 years agoUse k5-der.h in GSS library
Greg Hudson [Wed, 15 Mar 2023 17:56:21 +0000 (13:56 -0400)] 
Use k5-der.h in GSS library

Remove the DER implementations in lib/gssapi and use k5-der.h instead.

2 years agoAdd a simple DER support header
Greg Hudson [Tue, 7 Mar 2023 05:19:33 +0000 (00:19 -0500)] 
Add a simple DER support header

2 years agoMake k5buf more flexible for binary data
Greg Hudson [Mon, 13 Mar 2023 21:42:50 +0000 (17:42 -0400)] 
Make k5buf more flexible for binary data

Remove the invariant that buf.data is always zero-terminated, to allow
marshalling of binary data into precisely allocated fixed regions.
Add k5_buf_cstring() to zero-terminate the buffer and retrieve the
data pointer.  Adjust all callers that build C strings appropriately.

Add a k5_buf_add_byte() convenience wrapper alongside the integer
marshalling wrappers.  Change k5_buf_init_fixed() to accept a void
pointer so it can more conveniently be used with uint8_t arrays.

2 years agoUpdate copyright years to 2023
Greg Hudson [Fri, 24 Mar 2023 18:11:36 +0000 (14:11 -0400)] 
Update copyright years to 2023

2 years agoUse control flow guard flag in Windows builds 1293/head
gakamath [Tue, 28 Feb 2023 15:55:12 +0000 (21:25 +0530)] 
Use control flow guard flag in Windows builds

ticket: 9088 (new)

2 years agoModernize PAC code 1288/head
Greg Hudson [Fri, 25 Nov 2022 15:11:29 +0000 (10:11 -0500)] 
Modernize PAC code

Put the version and buffers directly in krb5_pac_data to avoid using a
variable-length array.  Use k5input for krb5_pac_parse().  Adjust some
names and comments.

2 years agoModernize default key data encryption functions 1289/head
Greg Hudson [Mon, 13 Feb 2023 20:08:56 +0000 (15:08 -0500)] 
Modernize default key data encryption functions

2 years agoFix possible double-free during KDB creation
Julien Rische [Wed, 1 Feb 2023 14:57:26 +0000 (15:57 +0100)] 
Fix possible double-free during KDB creation

In krb5_dbe_def_encrypt_key_data(), when we free
key_data->key_data_contents[0], reset it to null so the caller doesn't
free it as well.

Since commit a06945b4ec267e8b80e5e8c95edd89930ff12103 this bug
manifests as a double-free during KDB creation if master key
encryption fails.

[ghudson@mit.edu: edited commit message]

ticket: 9086 (new)
tags: pullup
target_version: 1.20-next

2 years agoAvoid using internal APIs in sim_client 1292/head
Greg Hudson [Fri, 24 Feb 2023 19:15:14 +0000 (14:15 -0500)] 
Avoid using internal APIs in sim_client

In sim_client.c, remove the calls to krb5_gen_portaddr() and
krb5_gen_replay_name() as they don't do anything after commit
dcb853ac32779b173f39e19c0f24b0087de85771.  Remove them, and include
krb5.h plus appropriate system headers rather than k5-int.h.

Also use a subkey when negotiating the auth context.  Kerberos
application protocols should generally use subkeys to prevent
cross-connection replay attacks.

2 years agoFix meridian type in getdate.y 1290/head
Julien Rische [Tue, 21 Feb 2023 09:03:35 +0000 (10:03 +0100)] 
Fix meridian type in getdate.y

Commit d3356bc42191c1896ab06835a2fb245e00471420 (ticket 8927)
incorrectly tagged tMERIDIAN as <Number>.  So while the lexer assigns
meridian values to the Meridian union field, the parser erroneously
reads them from the Number field.  On 64-bit IBM zSystems (s390x),
this can result in using the most recently read number as a meridian
value, leading to an abort in ToSeconds().

Fix the tMERIDIAN token type to be <Meridian>.

[ghudson@mit.edu: edited commit message]

ticket: 9087 (new)
tags: pullup
target_version: 1.20-next

2 years agoFix read overruns in SPNEGO parsing
Greg Hudson [Wed, 8 Feb 2023 17:23:28 +0000 (12:23 -0500)] 
Fix read overruns in SPNEGO parsing

Fix three read overruns discovered by the GitHub Security Lab team
(GHSL-2023-016, GHSL-2023-017, and GHSL-2023-018) using OSS-Fuzz.

In get_mech_set(), error out if gss_add_oid_set_member() fails rather
than continue the loop and increment i past the current bound of
returned_mechSet.  In g_verify_neg_token_init(), check for zero-byte
sequences before reading tag bytes, and reduce cur_size by one to
account for the tag byte when calling gssint_get_der_length().

ticket: 9085 (new)
tags: pullup
target_version: 1.20-next
target_version: 1.19-next

2 years agoAdd margin to expired tickets in test suite 1287/head
Greg Hudson [Sat, 28 Jan 2023 01:13:12 +0000 (20:13 -0500)] 
Add margin to expired tickets in test suite

Very occasionally a test using expired tickets will fail because the
ticket isn't seen as expired.  Obtain tickets with a longer expiration
margin to avoid these failures.

2 years agoFix t_ndr to return a define value from main()
Greg Hudson [Sat, 28 Jan 2023 01:22:32 +0000 (20:22 -0500)] 
Fix t_ndr to return a define value from main()

2 years agoAdd PAC full checksums 1284/head
Greg Hudson [Thu, 22 Dec 2022 08:05:23 +0000 (03:05 -0500)] 
Add PAC full checksums

A paper by Tom Tervoort noted that computing the PAC privsvr checksum
over only the server checksum is vulnerable to collision attacks
(CVE-2022-37967).  In response, Microsoft has added a second KDC
checksum over the full contents of the PAC.  Generate and verify full
KDC checksums in PACs for service tickets.  Update the t_pac.c ticket
test case to use a ticket issued by a recent version of Active
Directory (provided by Stefan Metzmacher).

ticket: 9084 (new)

2 years agoDon't issue session keys with deprecated enctypes 1283/head
Greg Hudson [Fri, 16 Dec 2022 23:31:07 +0000 (18:31 -0500)] 
Don't issue session keys with deprecated enctypes

A paper by Tom Tervoort noted that rc4-hmac pre-hashes the input for
its checksum and GSS operations before applying HMAC, and is therefore
potentially vulnerable to hash collision attacks if a protocol
contains a restricted signing oracle.

In light of these potential attacks, begin the functional deprecation
of DES3 and RC4 by disallowing their use as session key enctypes by
default.  Add the variables allow_des3 and allow_rc4 in case
negotiability of these enctypes for session keys needs to be turned
back on, with the expectation that in future releases the enctypes
will be more comprehensively deprecated.

ticket: 9081

2 years agoIn KDC, assume all services support aes256-sha1
Greg Hudson [Wed, 14 Dec 2022 18:20:46 +0000 (13:20 -0500)] 
In KDC, assume all services support aes256-sha1

To facilitate negotiating session keys with acceptable security,
assume that services support aes256-cts-hmac-sha1 unless a
session_enctypes string attribute says otherwise.

ticket: 9075

2 years agoRemove man page includes from RST documentation 1286/head
Greg Hudson [Wed, 4 Jan 2023 16:10:53 +0000 (11:10 -0500)] 
Remove man page includes from RST documentation

Rewrite parts of database.rst and appl_servers.rst to avoid including
full option descriptions from the (already linked) man pages.

2 years agoFix PKINIT CMS error checking for older OpenSSL 1281/head
Greg Hudson [Tue, 13 Dec 2022 18:15:28 +0000 (13:15 -0500)] 
Fix PKINIT CMS error checking for older OpenSSL

Commit 70f61d417261ca17efe3d60d180033bea2da60b0 updated the
CMS_verify() error code checks, using two error codes new to OpenSSL
3.0 (RSA_R_DIGEST_NOT_ALLOWED and CMS_R_UNKNOWN_DIGEST_ALGORITHM).
This change broke the build for OpenSSL 1.0 and 1.1.

Instead of looking for codes indicating an algorithm issue and
assuming that everything else is an invalid signature, check for the
code indicating an invalid signature and assume that everything else
is an algorithm issue.

ticket: 9069

2 years agoFix policy DB fallback error handling 1280/head
Greg Hudson [Mon, 12 Dec 2022 19:36:47 +0000 (14:36 -0500)] 
Fix policy DB fallback error handling

In osa_adb_open_and_lock(), if the btree dbopen() call returns EINVAL
or EFTYPE and the fallback hash dbopen() call also returns an error,
release the lock and return an error instead of returning success with
a null database.

ticket: 9082 (new)

2 years agoFix kpropd crash with unrecognized option 1285/head
abushwang [Wed, 28 Dec 2022 07:06:02 +0000 (15:06 +0800)] 
Fix kpropd crash with unrecognized option

ticket: 9083 (new)
tags: pullup
target_version: 1.20-next
target_version: 1.19-next

2 years agoRemove unused Unicode functions 1279/head
Greg Hudson [Sat, 10 Dec 2022 06:26:36 +0000 (01:26 -0500)] 
Remove unused Unicode functions

2 years agoSimplify krb5_chpw_message() UTF-8 processing
Greg Hudson [Sat, 10 Dec 2022 05:40:44 +0000 (00:40 -0500)] 
Simplify krb5_chpw_message() UTF-8 processing

Only validate the message as a UTF-8 string, rather than normalizing
it.

2 years agoRemove line continuations in et_c.awk 1276/head
gakamath [Mon, 28 Nov 2022 14:26:23 +0000 (19:56 +0530)] 
Remove line continuations in et_c.awk

Line continuations cause issues for the awk in MinGW, so just have
long lines instead.

[ghudson@mit.edu: rewrote commit message; factored out some string
constructions for readability]

2 years agoFix gic_keytab crash on memory exhaustion 1275/head
ChenChen Zhou [Sun, 27 Nov 2022 14:57:14 +0000 (22:57 +0800)] 
Fix gic_keytab crash on memory exhaustion

get_as_key_keytab() does not check the result of krb5_copy_keyblock(),
and dereferences a null pointer if it fails.  Remove the call and
steal the memory from kt_ent instead.

[ghudson@mit.edu: rewrote commit message; fixed comments]

ticket: 9080 (new)

2 years agoFix preauth crash on memory exhaustion 1274/head
ChenChen Zhou [Sun, 27 Nov 2022 14:24:24 +0000 (22:24 +0800)] 
Fix preauth crash on memory exhaustion

In k5_preauth_request_context_init(), check the result of calloc().

[ghudson@mit.edu: rewrote commit message; added free() of reqctx on error]

ticket: 9079 (new)

2 years agoFix profile crash on memory exhaustion 1273/head
ChenChen Zhou [Thu, 24 Nov 2022 13:59:21 +0000 (21:59 +0800)] 
Fix profile crash on memory exhaustion

In profile_get_values(), if init_list() fails to allocate values.list,
end_list() will dereference a null pointer.  Fix end_list() to handle
list->list being null.

[ghudson@mit.edu: rewrote commit message]

ticket: 9078 (new)

2 years agoFix aclocal.m4 syntax error for autoconf 2.72 1272/head
Julien Rische [Thu, 17 Nov 2022 14:01:24 +0000 (15:01 +0100)] 
Fix aclocal.m4 syntax error for autoconf 2.72

An incorrect closure inside KRB5_AC_INET6 is innocuous with autoconf
versions up to 2.71, but will cause an error at configure time with
the forthcoming autoconf 2.72.

[ghudson@mit.edu: added more context to commit message]

ticket: 9077 (new)
tags: pullup
target_version: 1.20-next
target_version: 1.19-next

2 years agoAdd Georgian translation 1271/head
NorwayFun [Wed, 9 Nov 2022 07:24:37 +0000 (08:24 +0100)] 
Add Georgian translation

[ghudson@mit.edu: added the translation to po/Makefile.in]

2 years agoUse memmove() in Unicode functions
Greg Hudson [Tue, 18 Oct 2022 20:17:55 +0000 (16:17 -0400)] 
Use memmove() in Unicode functions

Where the upstream OpenLDAP code uses AC_MEMCPY(), use memmove()
instead of memcpy() as the copies frequently involve overlapping
memory regions.  Credit to OSS-Fuzz for discovering one instance of
the issue.

ticket: 9076 (new)

2 years agoFix integer overflows in PAC parsing
Greg Hudson [Tue, 18 Oct 2022 00:25:11 +0000 (20:25 -0400)] 
Fix integer overflows in PAC parsing

In krb5_parse_pac(), check for buffer counts large enough to threaten
integer overflow in the header length and memory length calculations.
Avoid potential integer overflows when checking the length of each
buffer.  Credit to OSS-Fuzz for discovering one of the issues.

CVE-2022-42898:

In MIT krb5 releases 1.8 and later, an authenticated attacker may be
able to cause a KDC or kadmind process to crash by reading beyond the
bounds of allocated memory, creating a denial of service.  A
privileged attacker may similarly be able to cause a Kerberos or GSS
application service to crash.  On 32-bit platforms, an attacker can
also cause insufficient memory to be allocated for the result,
potentially leading to remote code execution in a KDC, kadmind, or GSS
or Kerberos application server process.  An attacker with the
privileges of a cross-realm KDC may be able to extract secrets from a
KDC process's memory by having them copied into the PAC of a new
ticket.

ticket: 9074 (new)
tags: pullup
target_version: 1.20-next
target_version: 1.19-next

2 years agoFix null deref in KDC when decoding invalid NDR
Greg Hudson [Wed, 12 Oct 2022 04:46:52 +0000 (00:46 -0400)] 
Fix null deref in KDC when decoding invalid NDR

In ndr_dec_delegation_info(), keep di->transited_services_length valid
by incrementing it as we add entries.  Otherwise
ndr_free_delegation_info() could dereference a null
di->transited_services field.  Also bound nservices using data->length
to prevent inordinately large memory allocations.  Credit to OSS-Fuzz
for discovering the issues.

ticket: 9073 (new)
tags: pullup
target_version: 1.20-next

2 years agoAvoid small read overrun in UTF8 normalization
Greg Hudson [Wed, 12 Oct 2022 04:27:17 +0000 (00:27 -0400)] 
Avoid small read overrun in UTF8 normalization

In krb5int_utf8_normalize(), check the length of the current character
against the buffer length before reading more than one byte.  Credit
to OSS-Fuzz for discovering the overrun.

ticket: 9072 (new)

2 years agoFix typo in TRACE_FAST_ARMOR_CCACHE_KEY message 1270/head
Richard E. Silverman [Fri, 28 Oct 2022 18:36:26 +0000 (14:36 -0400)] 
Fix typo in TRACE_FAST_ARMOR_CCACHE_KEY message

2 years agoRefactor KDC TGS processing code 1265/head
Greg Hudson [Tue, 9 Aug 2022 16:22:43 +0000 (12:22 -0400)] 
Refactor KDC TGS processing code

Split the TGS processing code into information gathering, constraint
and policy checking, and ticket-issuing steps, using a structure to
hold the gathered information.  Split validate_tgs_request() into
validate_tgs_constraints() and check_tgs_policy() for better auditing.
Fold kdc_process_s4u2proxy_req() into check_tgs_policy(), except for
the get_pac_princ_with_realm() step which is now performed in
gather_tgs_req_info().  Modify some other utility functions to fit the
new design.

2 years agoAdd and use ts_interval() helper 1266/head
Greg Hudson [Mon, 19 Sep 2022 19:18:50 +0000 (15:18 -0400)] 
Add and use ts_interval() helper

ts_delta() returns a signed result, which cannot hold an interval
larger than 2^31-1 seconds.  Intervals like this have been seen when
admins set password expiration dates more than 68 years in the future.

Add a second helper ts_interval() which returns an unsigned result,
and has the arguments reversed so that the start time is first.  Use
it in warn_pw_expiry() to handle the password expiration case, in the
GSS krb5 mech where we return an unsigned context or credential
lifetime to the caller, and in the KEYRING ccache type where we
compute an unsigned keyring timeout.

ticket: 9071 (new)

2 years agoUpdate error checking for OpenSSL CMS_verify 1264/head
Julien Rische [Thu, 28 Jul 2022 13:20:12 +0000 (15:20 +0200)] 
Update error checking for OpenSSL CMS_verify

The code for CMS data verification was initially written for OpenSSL's
PKCS7_verify() function.  It now uses CMS_verify(), but error handling
is still done using PKCS7_verify() error identifiers.  Update the
recognized error codes so that the KDC generates
KDC_ERR_DIGEST_IN_SIGNED_DATA_NOT_ACCEPTED errors when appropriate.
Use ERR_peek_last_error() to observe the error generated closest to
the API surface.

[ghudson@mit.edu: edited commit message]

ticket: 9069 (new)
tags: pullup
target_version: 1.20-next

3 years agoAvoid protocol error constants in KDC code 1263/head
Greg Hudson [Thu, 21 Jul 2022 17:32:50 +0000 (13:32 -0400)] 
Avoid protocol error constants in KDC code

For simplicity, return com_err codes from validate_as_request() and
validate_tgs_request() instead of protocol error constants.

3 years agoFix k5test.py exit handler
Greg Hudson [Thu, 21 Jul 2022 19:33:11 +0000 (15:33 -0400)] 
Fix k5test.py exit handler

Commit 0b4580b09afe9791d81961c41f61e4f06edad58f mistakenly calls the
nonexistent _stop_daemon() in the onexit handler.  Replace the call
with code to terminate the daemon and check its exit status.

3 years agoRemove kdc_context, tgs_server macros in KDC 1262/head
Greg Hudson [Mon, 18 Jul 2022 21:36:15 +0000 (17:36 -0400)] 
Remove kdc_context, tgs_server macros in KDC

Eliminate the last two kdc_active_realm macros from realm_data.h (left
behind after commits 0a2f14f752c32a24200363cc6b6ae64a92f81379 and
e987546b4ff1689bb711cc46118ad9fc0a5613f6).  Where code is affected,
use the names "context" and "realm".  Pass contexts instead of realm
data structures to several functions which only need a context.

3 years agoRemove include_certchain parameter in PKINIT 1261/head
Greg Hudson [Tue, 12 Jul 2022 23:15:29 +0000 (19:15 -0400)] 
Remove include_certchain parameter in PKINIT

Every caller of cms_signeddata_create() and cms_envelopeddata_create()
passes 1 for include_certchain.  Remove the parameter and
unconditionally add the certificate chain.

3 years agoReduce SUBDIROBJLISTS repetition in makefiles 1260/head
Greg Hudson [Tue, 12 Jul 2022 19:17:48 +0000 (15:17 -0400)] 
Reduce SUBDIROBJLISTS repetition in makefiles

Where applicable, define STOBJLISTS in terms of SUBDIROBJLISTS.

3 years agoRemove pre-CMS PKINIT compatibility code 1259/head
Greg Hudson [Mon, 11 Jul 2022 14:49:38 +0000 (10:49 -0400)] 
Remove pre-CMS PKINIT compatibility code

CMS support is present in OpenSSL 1.0, which is the earliest supported
version.

3 years agoSet reasonable supportedCMSTypes in PKINIT 1254/head
Julien Rische [Wed, 1 Jun 2022 16:02:04 +0000 (18:02 +0200)] 
Set reasonable supportedCMSTypes in PKINIT

The PKINIT client uses AuthPack.supportedCMSTypes to let the KDC know
the algorithms it supports for verification of the CMS data signature.
(The MIT krb5 KDC currently ignores this list, but other
implementations use it.)

Replace 3DES with sha512WithRSAEncryption and sha256WithRSAEncryption.

[ghudson@mit.edu: simplified code and used appropriate helpers; edited
commit message]

ticket: 9066 (new)

3 years agoSimplify plugin loading code 1258/head
Greg Hudson [Thu, 23 Jun 2022 20:41:40 +0000 (16:41 -0400)] 
Simplify plugin loading code

Remove the USE_CFBUNDLE code, which was only used by KfM.  Handle
platform conditionals according to current practice.  Use
k5_dir_filenames() instead of opendir() and remove the Windows
implementation of opendir().

3 years agoFix PKCS11 module path search
sashan [Fri, 17 Jun 2022 22:05:32 +0000 (00:05 +0200)] 
Fix PKCS11 module path search

Commit c5c11839e02c7993eb78f2c94c75c10cf93f2195 switched the loading
of the PKCS#11 module from dlopen() to krb5int_open_plugin().  Because
krb5int_open_plugin() includes a stat() test, this change has the
unintended consequence of requiring the module name to be an absolute
or relative path to the library, not a filename within the dynamic
linker search path.

Within krb5int_open_plugin(), only stat() the filename on the
platforms which will use the file type.

[ghudson@mit.edu: adjusted conditionals to call stat() on Windows;
rewrote commit message]

ticket: 9067 (new)
tags: pullup
target_version: 1.20-next

3 years agoFix build with -DDEBUG option 1257/head
sashan [Fri, 17 Jun 2022 22:17:10 +0000 (00:17 +0200)] 
Fix build with -DDEBUG option

DEBUG is not used in sserver.c, and defining it may conflict with
build options.

[ghudson@mit.edu: removed define instead of conditionalizing; edited
commit message]

3 years agoImprove k5test daemon checking 1255/head
Greg Hudson [Fri, 3 Jun 2022 18:28:26 +0000 (14:28 -0400)] 
Improve k5test daemon checking

Instead of checking daemon exit statuses prior to termination, check
them after we send SIGTERM.  This way we will notice when asan causes
an unsuccessful exit due to memory leaks, or when a daemon crashes in
its exit handling.

3 years agoFree verto context later in KDC cleanup
Greg Hudson [Fri, 3 Jun 2022 18:38:45 +0000 (14:38 -0400)] 
Free verto context later in KDC cleanup

The KDC supplies the verto context to kdcpreauth modules via the loop
method (added in commit 83b4ecd20e50ad330cd761977d5dadefe30a785b).
This context should remain valid until kdcpreauth modules are
unloaded, as modules might refer to it during cleanup.  In particular,
the OTP module references the verto context when freeing the RADIUS
client object (commit e89abc2d4ea1fea1ec28d470f297514b828e4842), which
can cause a memory error during KDC shutdown without this change.

ticket: 9064 (new)
tags: pullup
target_version: 1.20-next
target_version: 1.19-next

3 years agoFix memory leak in OTP kdcpreauth module
Greg Hudson [Fri, 3 Jun 2022 18:30:42 +0000 (14:30 -0400)] 
Fix memory leak in OTP kdcpreauth module

In otp_edata(), free the generated nonce.

ticket: 9063 (new)
tags: pullup
target_version: 1.20-next
target_version: 1.19-next

3 years agoFix uncommon PKINIT memory leak 1253/head
sashan [Sun, 29 May 2022 08:32:57 +0000 (10:32 +0200)] 
Fix uncommon PKINIT memory leak

PKINIT per-request module data objects are normally created by
pkinit_server_verify_padata() and freed by
pkinit_server_return_padata().  In some unusual circumstances, the KDC
may not call the return_padata method after verification succeeds.
Add a free_modreq method and free the object there instead.

[ghudson@mit.edu: rewrote commit message]

ticket: 9065 (new)
tags: pullup
target_version: 1.20-next
target_version: 1.19-next

3 years agoFix net-server.c when AI_NUMERICSERV is undefined 1252/head
Sergey Fedorov [Thu, 26 May 2022 17:06:38 +0000 (01:06 +0800)] 
Fix net-server.c when AI_NUMERICSERV is undefined

Some macOS versions do not define AI_NUMERICSERV.  Other source files
check whether it is defined before using it; do so here as well.

[ghudson@mit.edu: rewrote commit message; slightly changed approach]

ticket: 9062 (new)
tags: pullup
target_version: 1.20-next

3 years agoFix leaks in KDB test module 1251/head
sashan [Thu, 26 May 2022 06:47:33 +0000 (08:47 +0200)] 
Fix leaks in KDB test module

3 years agoFix memory leak in SPAKE kdcpreauth module
sashan [Thu, 26 May 2022 06:51:10 +0000 (08:51 +0200)] 
Fix memory leak in SPAKE kdcpreauth module

Commit ff57dc682a27bd205d715f3c0bed84890f2453c4 introduced a memory
leak into verify_response().  reply_key is no longer passed to the
callback and therefore needs to be freed by this function.

[ghudson@mit.edu: rewrote commit message]

ticket: 9061 (new)
tags: pullup
target_version: 1.20-next

3 years agoRead GSS configuration files with mtime 0 1249/head
Simo Sorce [Thu, 19 May 2022 16:27:40 +0000 (12:27 -0400)] 
Read GSS configuration files with mtime 0

There is at least one case (with flatpaks) where configuration files
in the special read-only /etc all have an mtime of 0.  Using an
initial last modified time of 0 in g_initialize.c causes these files
to never be read.

Change the initial high value to the be the "invalid" value
(time_t)-1.  Since the C and POSIX standards do not require time_t to
be signed, special-case the checks in load_if_changed() and
updateMechList() to treat all mod times as newer than -1.

[ghudson@mit.edu: edited commit message; slightly modified approach]

ticket: 9060 (new)
target_version: 1.20
tags: pullup